Skip to content

Commit

Permalink
chore: Update GitHub Actions workflow for releasing and publishing pa…
Browse files Browse the repository at this point in the history
…ckage
  • Loading branch information
teles committed May 18, 2024
1 parent 33c2047 commit f2ac9f9
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,46 @@
name: Release and Publish Package

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build
- name: Bump version and create a git tag

- name: Bump version, create tag, and push changes
id: bump_version
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
npm version patch -m "Bump version to %s [skip ci]"
echo ::set-output name=VERSION::$(node -p "require('./package.json').version")
- name: Push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://${{ secrets.GH_PAT }}@github.com/holly-sheets/holly-sheets.git
git push --follow-tags
env:
GH_PAT: ${{ secrets.GH_PAT }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
npm version patch -m "Bump version to %s [skip ci]"
git push --follow-tags
echo VERSION=$(node -p "require('./package.json').version") >> $GITHUB_ENV
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag_name: ${{ steps.bump_version.outputs.VERSION }}
release_name: Release ${{ steps.bump_version.outputs.VERSION }}
draft: false
prerelease: false
tag: ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit f2ac9f9

Please sign in to comment.