Release and publish package to npm #39
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: Release and publish package to npm | |
on: | |
workflow_dispatch: | |
inputs: | |
release-version: | |
description: 'Release version to manually set & publish. E.g. 0.34.0' | |
required: true | |
# release: | |
# types: [created] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 'lts/*' | |
registry-url: 'https://registry.npmjs.org' | |
- run: npm install -g npm | |
- name: bump release version | |
run: | | |
echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_VERSION)" >> $GITHUB_ENV | |
cat package.json | |
env: | |
RELEASE_VERSION: ${{ github.event.inputs.release-version }} | |
- name: print version | |
run: | | |
echo "VERSION=${{ env.NEW_VERSION }}" | |
- run: npm ci | |
- name: push changes to repository | |
#env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git status | |
# touch test/test.txt | |
#echo "NEW_VERSION=${{ env.NEW_VERSION }}" >> test/test.txt | |
# git add test/test.txt | |
git add package.json | |
git commit -m "chore(version): ${{ env.NEW_VERSION }}" | |
git tag ${{ env.NEW_VERSION }} | |
git status | |
git push && git push --tags | |
echo git push origin && echo git push --tags | |
- run: npm publish --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |