Skip to content

Commit

Permalink
fix(ci): simplify version bump in publish step
Browse files Browse the repository at this point in the history
  • Loading branch information
strumswell committed Aug 22, 2024
1 parent c0e0e52 commit 95e4b32
Showing 1 changed file with 10 additions and 62 deletions.
72 changes: 10 additions & 62 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,27 @@ on:
types: [published]

jobs:
prepare:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
- name: Restore node_modules cache
uses: actions/cache/restore@v3
id: cache
with:
path: node_modules
key: timestamp${{ hashFiles('package-lock.json') }}
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Cache node modules
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: node_modules
key: timestamp${{ hashFiles('package-lock.json') }}
update-version:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Update package.json version
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git fetch --all
git checkout main
git pull origin main

- name: Update version
run: |
VERSION=${GITHUB_REF#refs/tags/}
npm version ${VERSION#v} --no-git-tag-version --allow-same-version
git add package.json
git commit -m "chore(release): ${VERSION} [skip ci]"
git push origin main
publish:
needs: update-version
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
ref: main
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Unpack node_modules
uses: actions/cache/restore@v3
id: cache
with:
path: node_modules
key: timestamp${{ hashFiles('package-lock.json') }}
- name: Build and publish
run: |
npm run build
npm publish
- name: Build
run: npm run build

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

0 comments on commit 95e4b32

Please sign in to comment.