Skip to content

Commit

Permalink
fix(ci): externalize publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
strumswell committed Aug 22, 2024
1 parent d5a8872 commit e3acc2b
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 37 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ jobs:
run: npm run test:integration
env:
VITE_ANVIL_FORK_URL: ${{ secrets.VITE_ANVIL_FORK_URL }}

update_release_draft:
permissions:
contents: write
Expand All @@ -103,39 +102,3 @@ jobs:
commitish: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
needs: update_release_draft
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- 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: 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
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
81 changes: 81 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Publish Release

on:
release:
types: [published]

jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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') }}
- 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') }}
build:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
- name: Unpack node_modules
uses: actions/cache/restore@v3
id: cache
with:
path: node_modules
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
- 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: 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
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit e3acc2b

Please sign in to comment.