From 8e5febfc4711b37b0ceac1ab577600bc707f59c2 Mon Sep 17 00:00:00 2001 From: "Paul B." Date: Mon, 16 Dec 2024 14:49:04 +0100 Subject: [PATCH] =?UTF-8?q?release:=20fix=20the=20=E2=80=9Cpacking?= =?UTF-8?q?=E2=80=9D=20step=20for=20github=20releases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the major upgrade of Oclif in #587 we broke the releasing step of the CLI. This commit updates the release workflow aligning with the [latest suggestion from oclif](https://github.com/oclif/oclif/blob/458437e5572b496d7eaf84c33b710eaf2f514b33/templates/cli/shared/.github/workflows/onPushToMain.yml.ejs#L14) --- .github/workflows/release.yml | 69 ++++++++++++++++------------------- README.md | 5 ++- package.json | 1 + 3 files changed, 35 insertions(+), 40 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bc45d358..1d774040 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,41 +1,15 @@ -name: Release +name: Release tag pushes on Github + on: - workflow_run: - workflows: [ "Developer checks" ] - types: [ completed ] + push: + tags: + - v** + jobs: - # This 'check_tag' job is a hack because Github doesn't provide the full ref from the - # original triggered workflow. Hopefully in the future we will only have to change - # the condition of the `release` job to: - # - # ${{ github.event.workflow_run.conclusion == 'success' && - # startsWith(github.event.workflow_run, 'refs/tag/v') }} - check_tag: - runs-on: ubuntu-latest - outputs: - run_release: ${{ steps.check-tag.outputs.run_jobs }} - tag: ${{ steps.check-tag.outputs.ref }} - steps: - - name: check reference of dependent workflow ${{ github.event.workflow_run.head_branch }} - id: check-tag - run: | - if [[ ${{ github.event.workflow_run.head_branch }} =~ v[0-9]+\.[0-9]+\.[0-9]+.* ]]; then - echo "::set-output name=run_jobs::true" - echo "::set-output name=ref::${{ github.event.workflow_run.head_branch }}" - else - echo "::set-output name=run_jobs::false" - fi release: - needs: [check_tag] - if: ${{ github.event.workflow_run.conclusion == 'success' && needs.check_tag.outputs.run_release == 'true' }} runs-on: ubuntu-latest - strategy: - matrix: - node_version: [ '16' ] steps: - - uses: actions/checkout@v2 - with: - ref: ${{ needs.check_tag.outputs.tag }} + - uses: actions/checkout@v4 - name: Cache node modules uses: actions/cache@v2 env: @@ -46,17 +20,36 @@ jobs: key: node-${{ matrix.node_version }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} restore-keys: | node-${{ matrix.node_version }}-build-${{ env.cache-name }}- - - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node_version }} + - uses: actions/setup-node@v4 + - name: Check if version already exists + id: version-check + run: | + package_version=$(node -p "require('./package.json').version") + exists=$(gh api repos/${{ github.repository }}/releases/tags/v$package_version >/dev/null 2>&1 && echo "true" || echo "") + + if [ -n "$exists" ]; + then + echo "Version v$package_version already exists" + echo "::warning file=package.json,line=1::Version v$package_version already exists - no release will be created. If you want to create a new release, please update the version in package.json and push again." + echo "skipped=true" >> $GITHUB_OUTPUT + else + echo "Version v$package_version does not exist. Creating release..." + echo "skipped=false" >> $GITHUB_OUTPUT + echo "tag=v$package_version" >> $GITHUB_OUTPUT + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: npm ci + if: ${{ steps.version-check.outputs.skipped == 'false' }} - run: npm run pack - - name: Release + if: ${{ steps.version-check.outputs.skipped == 'false' }} + - name: Create draft Github Release + if: ${{ steps.version-check.outputs.skipped == 'false' }} uses: softprops/action-gh-release@v1 with: files: dist/**/* draft: true - tag_name: ${{ needs.check_tag.outputs.tag }} + tag_name: ${{ steps.version-check.outputs.tag }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_REPOSITORY: bump-sh/cli diff --git a/README.md b/README.md index 957f4ac5..ff47980d 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ $ bump --help The Bump.sh CLI is used to interact with your API documentation hosted on Bump.sh by using the API of developers.bump.sh VERSION - bump-cli/2.8.0 linux-x64 node-v16.19.0 + bump-cli/2.9.1 linux-x64 node-v20.18.1 USAGE $ bump [COMMAND] @@ -102,7 +102,7 @@ COMMANDS You can also get some help anytime by adding `--help` to any command. Example: `bump deploy --help`. -## Prepare your Bump.sh account +### Prepare your Bump.sh account While some commands don't need any API token (`preview` or `diff`) you will need an access key if you want to interact with your Bump.sh documentation. @@ -330,3 +330,4 @@ This npm package starts at v2.0.0 for two main reasons: - Our [first version](https://github.com/bump-sh/bump-cli) of the Bump CLI was written in Ruby, starting at v2.0.0, which makes it clear we are working on our second version of the Bump CLI - The `bump-cli` package used to be [owned by Rico](https://github.com/rstacruz) which already published v1.x packages. If you are looking for the old npm package please head to [`@rstacruz/bump-cli` package](https://www.npmjs.com/package/@rstacruz/bump-cli). _A big thanks to Rico for transferring the ownership of the `bump-cli` package name!_ +w diff --git a/package.json b/package.json index 44397f1f..f04c7ae5 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "clean": "rm -rf dist/ oclif.manifest.json", "lint": "eslint . --ext .ts", "fmt": "eslint --fix . --ext .ts", + "pack": "oclif pack tarballs", "postpack": "shx rm -f oclif.manifest.json", "posttest": "npm run lint", "prepack": "npm run clean && npm run build && oclif manifest && oclif readme",