Merge pull request #50 from source-academy/109 #33
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 npm | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
verify: | |
name: Verify should publish | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
submodules: recursive | |
- name: Verify version has changed | |
# We use jq as `npm pkg get version` returns a quoted string | |
run: | | |
if [ "$(cat package.json | jq -r .version)" == "$(npm view java-slang version)" ]; then | |
echo "Version has not changed" | |
echo "UPDATE=false" >> "$GITHUB_OUTPUT" | |
else | |
echo "Version has changed"; | |
echo "UPDATE=true" >> "$GITHUB_OUTPUT" | |
fi | |
publish: | |
name: Publish to npm | |
needs: [verify] | |
if: ${{ needs.verify.outputs.UPDATE == 'true' }} | |
runs-on: ubuntu-latestg | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
submodules: recursive | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build | |
run: yarn build | |
- name: Publish to npm | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |