Skip to content

Commit

Permalink
add dry run logic to release
Browse files Browse the repository at this point in the history
  • Loading branch information
EmandM committed May 15, 2024
1 parent bb81a3c commit 86f2f24
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- id: variables
run: echo "version=$(npm pkg get version | sed 's/"//g')" >> $GITHUB_OUTPUT
- run: echo "Creating release for ts-mock-imports at version ${{ steps.variables.outputs.version }}"
run: |
local_version=$(npm pkg get version | sed 's/"//g')
hosted_version=$(npm show ts-mock-imports version)
if [[ $hosted_version == $local_version ]]; then
echo "is_dry_run=false" >> $GITHUB_OUTPUT
echo "version=$(npm pkg get version | sed 's/"//g')" >> $GITHUB_OUTPUT
echo "Creating release for ts-mock-imports at version $local_version"
else
echo "is_dry_run=true" >> $GITHUB_OUTPUT
fi
publish-npm:
needs: setup
Expand All @@ -31,7 +40,12 @@ jobs:
- run: npm ci
- run: npm run compile
# Publish to npm
- run: npm publish --access public
- run: |
cmd=( npm publish --access public )
if [[ ${{ needs.setup.outputs.do_dry_run }} == 'true' ]]; then
cmd+=( --dry-run )
fi
cmd[@]
env:
NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_NPM_TOKEN }}
Expand All @@ -55,13 +69,19 @@ jobs:
cat package.json
- run: echo registry=https://npm.pkg.github.com/emandm >> .npmrc
- run: npm publish
- run: |
cmd=( npm publish )
if [[ ${{ needs.setup.outputs.do_dry_run }} == 'true' ]]; then
cmd+=( --dry-run )
fi
cmd[@]
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
external_test:
runs-on: ubuntu-latest
needs: [setup, publish-npm]
if: ${{ needs.setup.outputs.do_dry_run }} == 'false'
steps:
- uses: actions/setup-node@v4
- uses: actions/checkout@v4
Expand Down

0 comments on commit 86f2f24

Please sign in to comment.