private-subdir #15
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: Publish to GitHub Packages | |
on: | |
push: | |
branches: | |
- master | |
paths: "package.json" | |
jobs: | |
publish-gpr: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
registry-url: https://npm.pkg.github.com/ | |
- name: Install jq | |
run: sudo apt-get install jq | |
- name: Check if version changed | |
id: version_changed | |
run: | | |
VERSION_OLD=$(git show ${{ github.event.before }}:package.json | jq -r .version) | |
VERSION_NEW=$(jq -r .version package.json) | |
if [ "$VERSION_OLD" != "$VERSION_NEW" ]; then | |
echo "Version changed from $VERSION_OLD to $VERSION_NEW" | |
echo "changed=true" >> $GITHUB_OUTPUT | |
else | |
echo "Version did not change" | |
echo "changed=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Publish to github | |
if: steps.version_changed.outputs.changed == 'true' | |
run: | | |
npm i | |
npm run build | |
npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} |