From 6ed65aee38b0e73fa594e6f5d2227463d686c030 Mon Sep 17 00:00:00 2001 From: Peter Murray <681306+peter-murray@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:13:11 +0000 Subject: [PATCH] Adding release workflow --- .github/workflows/release.yml | 126 ++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..223a081 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,126 @@ +name: Release + +run-name: Release ${{ inputs.version }} + +on: + workflow_dispatch: + inputs: + version: + type: string + required: true + +jobs: + build_and_test: + name: Build and test + + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: Build and Test + run: | + npm ci + npm run test --if-present + npm run build --if-present + npm run build-exe --if-present + + # - name: Check that build is clean + # run: | + # git diff --exit-code + + + validate_version: + name: Validate version number + runs-on: ubuntu-22.04 + + steps: + - name: Process version number as SemVer + id: semver + uses: peter-murray/semver-data-action@v1 + with: + version: ${{ inputs.version }} + + + release: + name: Release + + needs: + - validate_version + - build_and_test + + runs-on: ubuntu-22.04 + + steps: + - name: Process version number as SemVer + id: semver + uses: peter-murray/semver-data-action@v1 + with: + version: ${{ inputs.version }} + + - name: Checkout + uses: actions/checkout@v4 + + - name: Set git user + run: | + git config user.name github-actions + git config user.email github-actions@github.com + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: Version application + run: | + npm version ${{ steps.semver.outputs.semver }} + + - name: Build + run: | + npm ci + npm run build --if-present + npm run build-exe --if-present + + - name: Check that build is clean + id: clean_build + continue-on-error: true + run: | + git diff --exit-code + + - name: Update release + if: steps.clean_build.outcome == 'failure' + run: | + git add . + git commit -m "chore: Updating release files" + + - name: Update tags + if: steps.semver.outputs.isPreRelease == 'false' + run: | + git tag "v${{ steps.semver.outputs.semver }}" --force + git tag "v${{ steps.semver.outputs.major }}" --force + git tag "v${{ steps.semver.outputs.major }}.${{ steps.semver.outputs.minor }}" --force + git tag "v${{ steps.semver.outputs.major }}.${{ steps.semver.outputs.minor }}.${{ steps.semver.outputs.patch }}" --force + + git push origin ${{ github.ref_name }} + git push origin --tags --force + + - name: Attach CLI artifacts + uses: actions/upload-artifact@v3 + with: + name: cli + path: cli + + - name: Create release + uses: ncipollo/release-action@v1.13.0 + with: + artifacts: cli/* + prerelease: ${{ steps.semver.outputs.isPreRelease }} + tag: v${{ steps.semver.outputs.semver }} \ No newline at end of file