Skip to content

Commit

Permalink
fix(ci): move version bump commit before building
Browse files Browse the repository at this point in the history
  • Loading branch information
strumswell committed Aug 22, 2024
1 parent e3acc2b commit af9b0df
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: "20"
Expand All @@ -28,11 +30,37 @@ jobs:
with:
path: node_modules
key: timestamp${{ hashFiles('package-lock.json') }}
build:

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]"
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
build:
needs: update-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: main
- uses: actions/setup-node@v4
with:
node-version: "20"
Expand All @@ -45,13 +73,16 @@ jobs:
key: timestamp${{ hashFiles('package-lock.json') }}
- name: Build
run: npm run build

publish:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
ref: main
- uses: actions/setup-node@v4
with:
node-version: "20"
Expand All @@ -62,17 +93,6 @@ jobs:
with:
path: node_modules
key: timestamp${{ hashFiles('package-lock.json') }}
- name: Update version
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
VERSION=${GITHUB_REF#refs/tags/v}
npm version $VERSION --no-git-tag-version --allow-same-version
git add package.json
git commit -m "chore(release): ${VERSION} [skip ci]"
git push
- name: Build and publish
run: |
npm run build
Expand Down

0 comments on commit af9b0df

Please sign in to comment.