Skip to content

Commit e94135b

Browse files
committed
release: fix the “packing” step for github releases
Since the major upgrade of Oclif in bump-sh#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)
1 parent 4df43c5 commit e94135b

File tree

3 files changed

+33
-39
lines changed

3 files changed

+33
-39
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,15 @@
1-
name: Release
1+
name: Release tag pushes on Github
2+
23
on:
3-
workflow_run:
4-
workflows: [ "Developer checks" ]
5-
types: [ completed ]
4+
push:
5+
tags:
6+
- v**
7+
68
jobs:
7-
# This 'check_tag' job is a hack because Github doesn't provide the full ref from the
8-
# original triggered workflow. Hopefully in the future we will only have to change
9-
# the condition of the `release` job to:
10-
#
11-
# ${{ github.event.workflow_run.conclusion == 'success' &&
12-
# startsWith(github.event.workflow_run, 'refs/tag/v') }}
13-
check_tag:
14-
runs-on: ubuntu-latest
15-
outputs:
16-
run_release: ${{ steps.check-tag.outputs.run_jobs }}
17-
tag: ${{ steps.check-tag.outputs.ref }}
18-
steps:
19-
- name: check reference of dependent workflow ${{ github.event.workflow_run.head_branch }}
20-
id: check-tag
21-
run: |
22-
if [[ ${{ github.event.workflow_run.head_branch }} =~ v[0-9]+\.[0-9]+\.[0-9]+.* ]]; then
23-
echo "::set-output name=run_jobs::true"
24-
echo "::set-output name=ref::${{ github.event.workflow_run.head_branch }}"
25-
else
26-
echo "::set-output name=run_jobs::false"
27-
fi
289
release:
29-
needs: [check_tag]
30-
if: ${{ github.event.workflow_run.conclusion == 'success' && needs.check_tag.outputs.run_release == 'true' }}
3110
runs-on: ubuntu-latest
32-
strategy:
33-
matrix:
34-
node_version: [ '16' ]
3511
steps:
36-
- uses: actions/checkout@v2
37-
with:
38-
ref: ${{ needs.check_tag.outputs.tag }}
12+
- uses: actions/checkout@v4
3913
- name: Cache node modules
4014
uses: actions/cache@v2
4115
env:
@@ -46,17 +20,36 @@ jobs:
4620
key: node-${{ matrix.node_version }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
4721
restore-keys: |
4822
node-${{ matrix.node_version }}-build-${{ env.cache-name }}-
49-
- uses: actions/setup-node@v2
50-
with:
51-
node-version: ${{ matrix.node_version }}
23+
- uses: actions/setup-node@v4
24+
- name: Check if version already exists
25+
id: version-check
26+
run: |
27+
package_version=$(node -p "require('./package.json').version")
28+
exists=$(gh api repos/${{ github.repository }}/releases/tags/v$package_version >/dev/null 2>&1 && echo "true" || echo "")
29+
30+
if [ -n "$exists" ];
31+
then
32+
echo "Version v$package_version already exists"
33+
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."
34+
echo "skipped=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "Version v$package_version does not exist. Creating release..."
37+
echo "skipped=false" >> $GITHUB_OUTPUT
38+
echo "tag=v$package_version" >> $GITHUB_OUTPUT
39+
fi
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5242
- run: npm ci
43+
if: ${{ steps.version-check.outputs.skipped == 'false' }}
5344
- run: npm run pack
54-
- name: Release
45+
if: ${{ steps.version-check.outputs.skipped == 'false' }}
46+
- name: Create draft Github Release
47+
if: ${{ steps.version-check.outputs.skipped == 'false' }}
5548
uses: softprops/action-gh-release@v1
5649
with:
5750
files: dist/**/*
5851
draft: true
59-
tag_name: ${{ needs.check_tag.outputs.tag }}
52+
tag_name: ${{ steps.version-check.outputs.tag }}
6053
env:
6154
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6255
GITHUB_REPOSITORY: bump-sh/cli

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ COMMANDS
102102

103103
You can also get some help anytime by adding `--help` to any command. Example: `bump deploy --help`.
104104

105-
## Prepare your Bump.sh account
105+
### Prepare your Bump.sh account
106106

107107
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.
108108

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"clean": "rm -rf dist/ oclif.manifest.json",
7878
"lint": "eslint . --ext .ts",
7979
"fmt": "eslint --fix . --ext .ts",
80+
"pack": "oclif pack tarballs",
8081
"postpack": "shx rm -f oclif.manifest.json",
8182
"posttest": "npm run lint",
8283
"prepack": "npm run clean && npm run build && oclif manifest && oclif readme",

0 commit comments

Comments
 (0)