Skip to content

Commit

Permalink
ci: combine both jobs in release.yml into 1
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Feb 27, 2025
1 parent 41cb645 commit c17be8e
Showing 1 changed file with 22 additions and 36 deletions.
58 changes: 22 additions & 36 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ on:
- next

jobs:
create_release:
release_to_npm:
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
is_latest: ${{ steps.release_type.outputs.is_latest }}
is_new_version: ${{ steps.version_check.outputs.is_new_version }}

steps:
- name: Checkout 🛎️
Expand All @@ -21,6 +18,23 @@ jobs:
fetch-depth: 20
fetch-tags: false

- name: Setup Node version ⚙️
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- id: cache-yarn
name: Restore cached node modules ♻️
uses: actions/cache@v4
with:
path: |
.yarn/cache
node_modules
key: ${{ inputs.os }}-${{ inputs.node }}-release-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ inputs.os }}-${{ inputs.node }}-release
- id: version_check
name: Verify new version 🔍
run: |
Expand Down Expand Up @@ -64,50 +78,22 @@ jobs:
draft: false
prerelease: ${{ steps.release_type.outputs.is_latest != 'true' }}

publish_to_npm:
needs: create_release
if: ${{ needs.create_release.outputs.is_new_version == 'true' }}
runs-on: ubuntu-latest

steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
fetch-depth: 20
fetch-tags: false

- id: cache-yarn
name: Restore cached node modules ♻️
uses: actions/cache@v4
with:
path: |
.yarn/cache
node_modules
key: ${{ inputs.os }}-${{ inputs.node }}-release-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ inputs.os }}-${{ inputs.node }}-release
- name: Setup Node version ⚙️
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Install 🔧
if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }}
if: ${{ steps.version_check.outputs.is_new_version == 'true' }}
run: yarn --immutable

- name: Build 🔨
if: ${{ steps.version_check.outputs.is_new_version == 'true' }}
run: yarn build

- name: Publish with latest tag 🚀
if: ${{ needs.create_release.outputs.is_latest == 'true' }}
if: ${{ steps.version_check.outputs.is_new_version == 'true' && steps.release_type.outputs.is_latest == 'true' }}
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish with next tag 🚀
if: ${{ needs.create_release.outputs.is_latest != 'true' }}
if: ${{ steps.version_check.outputs.is_new_version == 'true' && steps.release_type.outputs.is_latest != 'true' }}
run: npm publish --access public --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit c17be8e

Please sign in to comment.