Skip to content

Commit 2da71c2

Browse files
Add publish steps to release job (#289)
* Add publish steps to release job * Update prepack script * Clean up publish steps
1 parent 7e66a48 commit 2da71c2

File tree

3 files changed

+42
-35
lines changed

3 files changed

+42
-35
lines changed

.github/workflows/build-main-publish-npm.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/release-on-github.yaml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ on:
1515
- patch
1616
default: minor
1717
jobs:
18-
release:
18+
bump-version:
1919
runs-on: ubuntu-latest
20+
21+
outputs:
22+
RELEASE_VERSION: ${{ steps.create_tags.outputs.RELEASE_VERSION }}
2023
permissions:
2124
contents: write
25+
2226
steps:
2327
- uses: actions/checkout@v3
2428

@@ -28,7 +32,7 @@ jobs:
2832

2933
- run: npm ci
3034

31-
- name: npm version...
35+
- name: Bump version and regenerate README
3236
run: |
3337
# https://github.com/orgs/community/discussions/26560
3438
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
@@ -37,11 +41,22 @@ jobs:
3741
npx oclif readme && node src/format-readme.js
3842
git commit -am "Release for ${VERSION}"
3943
git tag $VERSION
40-
echo "VERSION=${VERSION}" >> $GITHUB_ENV
44+
echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_OUTPUT
4145
echo "Released version ${VERSION}" >> $GITHUB_STEP_SUMMARY
46+
id: create_tags
4247

4348
- run: git push origin --follow-tags
44-
49+
50+
publish-github:
51+
runs-on: ubuntu-latest
52+
53+
needs: bump-version
54+
permissions:
55+
contents: write
56+
env:
57+
VERSION: ${{ needs.bump-version.outputs.RELEASE_VERSION }}
58+
59+
steps:
4560
- name: Create GitHub Release
4661
uses: octokit/request-action@v2.x
4762
id: create_release
@@ -54,3 +69,25 @@ jobs:
5469
generate_release_notes: true
5570
env:
5671
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
73+
publish-npm:
74+
runs-on: ubuntu-latest
75+
76+
needs: [bump-version, publish-github]
77+
env:
78+
VERSION: ${{ needs.bump-version.outputs.RELEASE_VERSION }}
79+
80+
steps:
81+
- uses: actions/checkout@v3
82+
83+
# Setup .npmrc file to publish to npm
84+
- uses: actions/setup-node@v3
85+
with:
86+
node-version: '18.x'
87+
registry-url: 'https://registry.npmjs.org'
88+
89+
- run: npm ci
90+
91+
- run: npm publish
92+
env:
93+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"repository": "SmartBear/swaggerhub-cli",
8383
"scripts": {
8484
"postpack": "rm -f oclif.manifest.json",
85-
"prepack": "oclif-dev manifest",
85+
"prepack": "npx oclif manifest",
8686
"test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
8787
"lint": "eslint ./src ./test",
8888
"postinstall": "node ./src/check-node-version"

0 commit comments

Comments
 (0)