NPM Publish #46
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: NPM Publish | |
on: | |
workflow_run: | |
workflows: ['Auto Tag and Release'] | |
types: [completed] | |
branches: | |
- 'main' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get latest tag | |
id: latest_tag | |
run: | | |
git fetch --tags | |
latest_tag=$(git tag --sort=-v:refname | head -n 1) | |
if [ -z "$latest_tag" ]; then | |
latest_tag="1.0.0" | |
fi | |
echo "::set-output name=tag::$latest_tag" | |
- name: set version from tag | |
run: echo "RELEASE_VERSION=${{ steps.latest_tag.outputs.tag }}" >> $GITHUB_ENV | |
- name: print version number | |
run: echo ${{ env.RELEASE_VERSION }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: configure git | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "astrum-forge" | |
- name: set pre-release version | |
run: npm version --prefix bvx-kit ${{ env.RELEASE_VERSION }} | |
- name: write version.js | |
run: rm -rf bvx-kit/src/version.ts && echo 'export default "${{ env.RELEASE_VERSION }}";' > bvx-kit/src/version.ts | |
- name: copy README | |
run: cp README.md bvx-kit/README.md | |
- name: copy LICENSE | |
run: cp LICENSE.md bvx-kit/LICENSE.md | |
- name: copy graphics | |
run: cp -R graphics bvx-kit/ | |
- name: NPM Login & Build | |
run: rm -rf bvx-kit/.npmrc && npm set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_PUBLISH_KEY }} && npm run --prefix bvx-kit clean:build | |
- uses: JS-DevTools/npm-publish@v3 | |
with: | |
package: ./bvx-kit/package.json | |
token: ${{ secrets.NPM_PUBLISH_KEY }} | |
access: 'public' |