Skip to content

Commit

Permalink
chore(ci): add versioned npm link
Browse files Browse the repository at this point in the history
  • Loading branch information
nihalgonsalves committed Apr 25, 2021
1 parent 238e63c commit 071ae34
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,39 @@ on:
- 'tsconfig.json'
- '.github/workflows/publish.yml'
jobs:
dry-run:
preview:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.result }}
steps:
- name: git config
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2
- run: yarn install --frozen-lockfile
- run: yarn standard-version --dry-run
# not dry-run, but this job doesn't commit or push anything anyway
# required to get the actual bumped version
- run: yarn standard-version
# yarn doesn't have an equivalent preview
- run: npm publish --dry-run
- id: version
uses: actions/github-script@v4
with:
result-encoding: string
script: |
const version = require('./package.json').version
core.warning(`Approving this deployment will publish version ${version}`)
return version
publish:
needs: [preview]
runs-on: ubuntu-latest
environment:
name: NPM
url: https://www.npmjs.com/package/@nihalgonsalves/esconfig
url: https://www.npmjs.com/package/@nihalgonsalves/esconfig/v/${{ needs.preview.outputs.version }}
steps:
- name: git config
run: |
Expand All @@ -46,16 +63,9 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn publish --non-interactive --access public
- run: git push --follow-tags origin main
- id: version
uses: actions/github-script@v4
with:
result-encoding: string
script: |
const pkg = require('./package.json')
return `v${pkg.version}`
- uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: CHANGELOG.md
tag_name: ${{ steps.version.outputs.result }}
tag_name: v${{ needs.preview.outputs.version }}

0 comments on commit 071ae34

Please sign in to comment.