From e2c73198fca6ee234d366a100a05e5126d621c4c Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Fri, 11 Oct 2024 02:34:07 -0400 Subject: [PATCH] ci: cleanup release action naming (#179) --- .changeset/tasty-avocados-poke.md | 5 +++ .github/workflows/create-release-pr.yaml | 42 ++++++++++++++++++ .github/workflows/pre-release.yaml | 54 ------------------------ .github/workflows/release-snapshot.yaml | 11 +---- .github/workflows/release.yaml | 4 +- package.json | 1 + 6 files changed, 52 insertions(+), 65 deletions(-) create mode 100644 .changeset/tasty-avocados-poke.md create mode 100644 .github/workflows/create-release-pr.yaml delete mode 100644 .github/workflows/pre-release.yaml diff --git a/.changeset/tasty-avocados-poke.md b/.changeset/tasty-avocados-poke.md new file mode 100644 index 00000000..17561134 --- /dev/null +++ b/.changeset/tasty-avocados-poke.md @@ -0,0 +1,5 @@ +--- +'@axelar-network/axelar-cgp-sui': patch +--- + +create an npm task for snapshot release and cleanup workflow names diff --git a/.github/workflows/create-release-pr.yaml b/.github/workflows/create-release-pr.yaml new file mode 100644 index 00000000..10d57fee --- /dev/null +++ b/.github/workflows/create-release-pr.yaml @@ -0,0 +1,42 @@ +# This workflow concerns the preparation of the `changeset` PR and keeping it updated by tracking the changes on `main` branch. +name: Create Release PR + +on: + workflow_dispatch: + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + create-release-pr: + name: Create Release PR + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Check for changeset files + run: | + if ! ls .changeset/*.md | grep -q '\.changeset\/[a-z-]\+\.md$'; then + echo "No changeset files found. Exiting workflow." + exit 1 + fi + + echo "Changeset files found. Continuing with the workflow." + + - name: Setup tools + uses: ./.github/actions/setup-tools + with: + install-nodejs: 'true' + + # Keep the version of the PRs up-to-date + - name: Create Release Pull Request + id: release-pr + uses: changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9 # v1.4.7 + with: + branch: 'main' + title: 'chore(release): bump version and update changelog' + commit: 'chore(release): bump version and update changelog' + env: + GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml deleted file mode 100644 index 9ff0405e..00000000 --- a/.github/workflows/pre-release.yaml +++ /dev/null @@ -1,54 +0,0 @@ -# This workflow concerns the preparation of the `changeset` PR and keeping it updated by tracking the changes on `main` branch. -name: Pre-Release Preparation - -on: - workflow_dispatch: - -concurrency: ${{ github.workflow }}-${{ github.ref }} - -jobs: - pre-release: - name: Pre-Release Preparation - runs-on: ubuntu-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Check for changeset files and 'pre-release' label exist - id: check-conditions - run: | - if ls .changeset/*.md | grep '\.changeset\/[a-z-]\+\.md$'; then - echo "has_changeset=true" >> "$GITHUB_OUTPUT" - else - echo "has_changeset=false" >> "$GITHUB_OUTPUT" - fi - - # Install Node.js and its dependencies - # Needed for the changeset releases - - name: Setup tools - uses: ./.github/actions/setup-tools - with: - install-nodejs: 'true' - - # Keep the version of the PRs up-to-date - - name: Create Release Pull Request - id: release-pr - if: ${{ steps.check-conditions.outputs.has_changeset == 'true' }} - uses: changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9 #v1.4.7 - with: - branch: 'main' - title: 'chore(release): bump version and update changelog' - commit: 'chore(release): bump version and update changelog' - env: - GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} - - - name: Update release PR Comment - if: ${{ steps.release-pr.outputs.pullRequestNumber != '' }} - uses: mshick/add-pr-comment@v2 - with: - message: | - **PR Associated with the Release**: [PR #${{steps.release-pr.outputs.pullRequestNumber}}](https://github.com/${{ github.repository }}/pull/${{ steps.release-pr.outputs.pullRequestNumber }}) - - Please make sure to review the PR before merging it in order to publish a release. diff --git a/.github/workflows/release-snapshot.yaml b/.github/workflows/release-snapshot.yaml index 0c6b36ed..4e954e5c 100644 --- a/.github/workflows/release-snapshot.yaml +++ b/.github/workflows/release-snapshot.yaml @@ -21,15 +21,8 @@ jobs: install-sui: 'true' install-nodejs: 'true' - - name: Build TS and SUI modules - run: npm run build - - - name: Set Snapshot Version - run: | - npm version 0.0.0-snapshot.$(git rev-parse --short HEAD) --git-tag-version=false - - - name: Publish Snapshot to NPM + - name: Build and Publish a Snapshot to NPM run: | - npm publish --no-git-checks --tag snapshot --access public + npm run release-snapshot env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0c2edc8b..54644f0e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -25,7 +25,7 @@ jobs: with: persist-credentials: false - - name: Setup the required tools (sui, nodejs) + - name: Setup tools uses: ./.github/actions/setup-tools with: install-sui: 'true' @@ -33,7 +33,7 @@ jobs: # Publishes a release in case the release isn't published - name: Publish release - uses: changesets/action@v1 + uses: changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9 # v1.4.7 with: publish: npm run release createGithubReleases: true diff --git a/package.json b/package.json index bdc91f17..92f2ed8f 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "test": "npm run test-move && npm run test-js", "coverage": "./scripts/coverage.sh", "release": "npm run build && changeset publish", + "release-snapshot": "npm run build && npm version 0.0.0-snapshot.$(git rev-parse --short HEAD) --git-tag-version=false && npm publish --no-git-checks --tag snapshot --access public", "cs": "changeset", "lint": "eslint --fix './src/*.ts' './test/*.js'", "prettier": "prettier --write './src/*.ts' './test/*.js'",