Skip to content

v1.0.8b

v1.0.8b #3

Workflow file for this run

name: Release to NPM
on:
release:
types: [published]
jobs:
release:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Node.js without caching
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
# Step 3: Clear npm cache
- name: Clear npm cache
run: npm cache clean --force
# Step 4: Install dependencies (without lock file)
- name: Install dependencies
run: npm install --no-package-lock
# Step 5: Sync package.json version with release tag
- name: Sync version with release tag
run: |
RELEASE_VERSION=${GITHUB_REF#refs/tags/}
echo "Updating package.json to version ${RELEASE_VERSION}"
npm version ${RELEASE_VERSION} --no-git-tag-version
# Step 6: Generate/update changelog
- name: Update changelog
run: npx standard-version --skip.tag --skip.commit
# Step 7: Authenticate with npm
- name: Authenticate with npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
# Step 8: Publish package to npm
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Step 9: Push updated files back to repository
- name: Push updated files back
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git checkout ${{ github.ref_name }}
git add package.json CHANGELOG.md
git commit -m "chore(release): ${GITHUB_REF#refs/tags/} [skip ci]" || echo "No changes to commit"
git push origin ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}