Fix update package version condition #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
check_if_sentry_updated: | |
name: Check whether Sentry was updated | |
outputs: | |
version_ok: ${{ steps.check.outputs.version_ok }} | |
sentry_version: ${{ steps.check.outputs.sentry_version }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout git repository | |
uses: actions/checkout@v4 | |
- name: Check whether Sentry was updated | |
id: check | |
run: | | |
sentryVersion="$(jq -r '.devDependencies."@sentry/node"' package.json)" | |
echo "version_ok=$(jq -r ".version == \"$sentryVersion\"" package.json)" >> $GITHUB_OUTPUT | |
echo "sentry_version=$sentryVersion" >> $GITHUB_OUTPUT | |
update_package_version: | |
name: Update package version if Sentry was updated | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
needs: check_if_sentry_updated | |
if: needs.check_if_sentry_updated.outputs.version_ok == 'false' | |
steps: | |
- name: Checkout git repository | |
uses: actions/checkout@v4 | |
- name: Set up node 18 environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: 'https://registry.npmjs.org' | |
- name: Update package.json, commit and push | |
run: | | |
updatedManifest=$(jq ".version = \"${{ needs.check_if_sentry_updated.outputs.sentry_version }}\"" package.json) | |
echo -E "${updatedManifest}" > package.json | |
git config --global user.name 'Action User' | |
git config --global user.email '[email protected]' | |
git add package.json | |
git commit -m "Bump version to ${{ needs.check_if_sentry_updated.outputs.sentry_version }}" | |
git push | |
- name: Build | |
run: | | |
npm ci | |
npm run build | |
- name: Publish | |
run: npm publish --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} | |
- name: Generate Github Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
make_latest: true | |
tag_name: v${{ needs.check_if_sentry_updated.outputs.sentry_version }} # update with known version |