From 8ea5aad876d9bd8c1cc68e0e7548aeedc68dc908 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Thu, 28 Jul 2022 14:50:55 +1000 Subject: [PATCH] ci(release): version bumper --- .github/actions/bump-manifest-version.js | 12 +++--- .github/workflows/release.yml | 47 +++++++++++++++++++----- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/.github/actions/bump-manifest-version.js b/.github/actions/bump-manifest-version.js index c4aab9f..5fe3462 100644 --- a/.github/actions/bump-manifest-version.js +++ b/.github/actions/bump-manifest-version.js @@ -1,10 +1,10 @@ -const fs = require('fs') +const fs = require('fs'); -const version = process.env.TGT_RELEASE_VERSION -const newVersion = version.replace('v', '') +const version = process.env.TGT_RELEASE_VERSION; +const newVersion = version.replace('v', ''); -const manifestFile = fs.readFileSync('fxmanifest.lua', {encoding: 'utf8'}) +const manifestFile = fs.readFileSync('fxmanifest.lua', { encoding: 'utf8' }); -const newFileContent = manifestFile.replace(/\bversion\s+(.*)$/gm, `version '${newVersion}'`) +const newFileContent = manifestFile.replace(/\bversion\s+(.*)$/gm, `version '${newVersion}'`); -fs.writeFileSync('fxmanifest.lua', newFileContent) \ No newline at end of file +fs.writeFileSync('fxmanifest.lua', newFileContent); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7d311e9..554e6df 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,34 +1,42 @@ -name: Release +name: Build on: push: tags: - - 'v*' + - 'v*.*.*' jobs: create-release: - name: Build and Create Tagged Release + name: Build and Create Tagged release runs-on: ubuntu-latest + steps: - name: Install archive tools run: sudo apt install zip - - uses: actions/checkout@v2 + - name: Checkout source code + uses: actions/checkout@v2 with: fetch-depth: 0 - ref: ${{ github.ref }} - - uses: pnpm/action-setup@v2.0.1 + ref: ${{ github.event.repository.default_branch }} + + - name: Install pnpm + uses: pnpm/action-setup@v2.0.1 with: version: 6.20.3 + - name: Get variables + id: get_vars + run: | + echo '::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)' + echo '::set-output name=DATE::$(date +'%D')' + - name: Setup node uses: actions/setup-node@v2 with: node-version: 16.x cache: 'pnpm' - - - name: Set env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + cache-dependency-path: 'pnpm-lock.yaml' - name: Install dependencies run: pnpm i @@ -36,6 +44,25 @@ jobs: - name: Run build run: pnpm build + - name: Bump manifest version + run: node .github/actions/bump-manifest-version.js + env: + TGT_RELEASE_VERSION: ${{ github.ref_name }} + + - name: Push manifest change + uses: EndBug/add-and-commit@v8 + with: + add: fxmanifest.lua + push: true + author_name: Manifest Bumper + author_email: 41898282+github-actions[bot]@users.noreply.github.com + message: 'chore: bump manifest version to ${{ github.ref_name }}' + + - name: Update tag ref + uses: EndBug/latest-tag@latest + with: + tag-name: ${{ github.ref_name }} + - name: Bundle files run: | mkdir -p ./temp/oxmysql @@ -52,7 +79,7 @@ jobs: id: auto_release with: repo_token: '${{ secrets.GITHUB_TOKEN }}' - title: ${{ env.RELEASE_VERSION }} + title: '${{ env.RELEASE_VERSION }}' prerelease: false files: oxmysql.zip