Skip to content

Commit

Permalink
fix: Add dry run logic to release (#55)
Browse files Browse the repository at this point in the history
* fix: use-generated-version

* add dry run logic to release
  • Loading branch information
EmandM authored May 15, 2024
1 parent 7b1da20 commit a845c54
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 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
7 changes: 5 additions & 2 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ jobs:
else
cmd+=( ${{ inputs.semver_type }} )
fi
echo "Running ${cmd[@]}"
echo "Running $cmd"
new_version="${cmd[@]}"
echo "Created version $new_version"
git push && git push --tags
echo "version_number=$(npm pkg get version | sed 's/"//g')" >> $GITHUB_OUTPUT
echo "version_number=$new_version" >> $GITHUB_OUTPUT
- id: pack_tar
run: |
Expand Down

0 comments on commit a845c54

Please sign in to comment.