Skip to content

Commit

Permalink
Move npm publish step into build script, but only for newest supporte…
Browse files Browse the repository at this point in the history
…d node version in the cloud
  • Loading branch information
kj4ezj committed Aug 2, 2024
1 parent 8bd905c commit d664aba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,14 @@ jobs:
- name: Test - node v${{ matrix.node-version }}
run: yarn test

- name: Package - node v${{ matrix.node-version }}
- name: Build - node v${{ matrix.node-version }}
run: yarn build
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_API_KEY }}
NODE_MAJOR_VERSION: ${{ matrix.node-version }}

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: kj4ezj-is-${{ matrix.node-version }}
path: kj4ezj-is-*.tgz

- name: Publish to NPM
run: npm publish --provenance --access public
if: startsWith(github.ref, 'refs/tags/')
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_API_KEY }}
12 changes: 12 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ if [[ "$CI" == 'true' ]]; then
echo 'Validating package can be installed...'
ee 'npm install -g kj4ezj-is-*.tgz'
fi
# publish
echo 'Publishing...'
if [[ -z "$GIT_TAG" ]]; then
printf '\e[1;33mNOTICE: Not a tagged build, no software will be published.\e[0m\n'
elif [[ "$CI" != 'true' || -n "$ACT" ]]; then
printf '\e[1;33mNOTICE: Skipping publish step for local build.\e[0m\n'
elif [[ "$NODE_MAJOR_VERSION" != "$(cat .nvmrc | tr -d '[:space:]')" ]]; then
printf '\e[1;33mNOTICE: Skipping publish step for older Node.js matrix job.\e[0m\n'
else
ee 'npm publish --provenance --access public'
printf '\e[1;32mPublished to npm!\e[0m\n'
fi
# clean up
ee mv package.json.$UNIX_TIME.bak package.json
popd
Expand Down

0 comments on commit d664aba

Please sign in to comment.