From 393195e333b3f21a82eaddc7ec658ae03fc4516b Mon Sep 17 00:00:00 2001 From: Gavan Lamb Date: Sun, 16 Jun 2024 13:52:19 +1000 Subject: [PATCH] feat(GH-8): Update release workflow and remove preview --- .github/workflows/preview.yml | 113 ---------------------------------- .github/workflows/release.yml | 59 ++++++++++++++---- 2 files changed, 46 insertions(+), 126 deletions(-) delete mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml deleted file mode 100644 index 23226d0..0000000 --- a/.github/workflows/preview.yml +++ /dev/null @@ -1,113 +0,0 @@ -name: 'Preview' - -on: - pull_request: - -concurrency: - cancel-in-progress: false - group: preview-${{ github.ref_name }} - -jobs: - build: - name: Build - runs-on: ubuntu-latest - outputs: - sem-ver: ${{ steps.get-version.outputs.semVer }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version-file: .node-version - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v1.1.1 - with: - versionSpec: '5.x' - - name: Get version - id: get-version - uses: gittools/actions/gitversion/execute@v1.1.1 - with: - targetPath: ./ - disableCache: true - useConfigFile: true - configFilePath: GitVersion.yml - env: - BUILD_NUMBER: ${{ github.run_number }} - - - name: Restore dependencies - run: npm ci - - - name: Lint - run: npm run lint - - - name: Test - run: npm run test - - - name: Publish test results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() - with: - files: | - ./test-results/junit.xml - - - name: Package - run: npm run package - - - name: Verify changed files - uses: tj-actions/verify-changed-files@v20 - id: verify-changed-files - with: - fail-if-changed: true - fail-message: Files in the dist folder are not up-to-date. Please run 'npm run package' locally and commit the changes. - files: | - dist - - - name: Qodana Scan - uses: JetBrains/qodana-action@v2024.1 - env: - QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} - use-annotations: true - - release: - name: Release - runs-on: ubuntu-latest - permissions: - contents: write - needs: - - build - env: - tag: v${{ needs.build.outputs.sem-ver }} - environment: release - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - name: Create and push tag - run: | - git config user.name '${{ github.actor }}' - git config user.email '${{ github.actor }}@users.noreply.github.com' - git remote set-url origin https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }} - git tag -a ${{ env.tag }} -m "${{ env.tag }}}" - git push origin tag ${{ env.tag }} - - name: Create release notes - uses: mikepenz/release-changelog-builder-action@v5.0.0-a02 - id: create-release-notes - with: - configuration: release-notes-config.yml - failOnError: false - toTag: ${{ github.sha }} - token: ${{ github.token }} - - name: Create release - uses: softprops/action-gh-release@v2 - with: - body: ${{ steps.build-release-notes.outputs.changelog }} - tag_name: ${{ env.tag }} - make_latest: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 53c582b..2fd71b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,7 @@ -name: 'Preview' +name: 'Release' on: + pull_request: push: branches: - main @@ -13,6 +14,8 @@ jobs: build: name: Build runs-on: ubuntu-latest + outputs: + sem-ver: ${{ steps.get-version.outputs.semVer }} steps: - name: Checkout uses: actions/checkout@v4 @@ -40,9 +43,6 @@ jobs: env: BUILD_NUMBER: ${{ github.run_number }} - - name: Set version - run: npm version ${{ steps.get-version.outputs.semVer }} - - name: Restore dependencies run: npm ci @@ -59,23 +59,56 @@ jobs: files: | ./test-results/junit.xml - - name: Publish test coverage - uses: ArtiomTr/jest-coverage-report-action@v2 - if: always() - with: - skip-step: all - coverage-file: ./test-results/summary.json - base-coverage-file: ./test-results/summary.json - - name: Package run: npm run package + - name: Verify changed files + uses: tj-actions/verify-changed-files@v20 + id: verify-changed-files + with: + fail-if-changed: true + fail-message: Files in the dist folder are not up-to-date. Please run 'npm run package' locally and commit the changes. + files: | + dist + + - name: Qodana Scan + uses: JetBrains/qodana-action@v2024.1 + env: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} + use-annotations: true + release: - name: release + name: Release runs-on: ubuntu-latest + needs: + - build + env: + tag: v${{ needs.build.outputs.sem-ver }} + environment: Production steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 fetch-tags: true + - name: Create and push tag + run: | + git config user.name '${{ github.actor }}' + git config user.email '${{ github.actor }}@users.noreply.github.com' + git remote set-url origin https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }} + git tag -a ${{ env.tag }} -m "${{ env.tag }}}" + git push origin tag ${{ env.tag }} + - name: Create release notes + uses: mikepenz/release-changelog-builder-action@v5.0.0-a02 + id: create-release-notes + with: + configuration: release-notes-config.yml + failOnError: false + toTag: ${{ github.sha }} + token: ${{ github.token }} + - name: Create release + uses: softprops/action-gh-release@v2 + with: + body: ${{ steps.build-release-notes.outputs.changelog }} + tag_name: ${{ env.tag }} + make_latest: true