Skip to content
This repository was archived by the owner on Jul 2, 2026. It is now read-only.

Commit c0fc7b5

Browse files
committed
fix: simplify workflow
1 parent e99dd1b commit c0fc7b5

2 files changed

Lines changed: 6 additions & 37 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: npm-publish
33
on:
44
workflow_call:
55
inputs:
6-
branch:
6+
tag:
77
required: true
88
type: string
99
nodeVersion:
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818
with:
19-
ref: ${{ inputs.branch }}
19+
ref: ${{ inputs.tag }}
2020

2121
- name: Setup Node.js
2222
uses: actions/setup-node@v4
@@ -41,21 +41,8 @@ jobs:
4141
run: npm run build
4242

4343
- name: Determine npm dist-tag
44+
uses: salesforcecli/github-workflows/.github/actions/getPreReleaseTag@main
4445
id: distTag
45-
run: |
46-
# Extract version from package.json
47-
VERSION=$(node -p "require('./package.json').version")
48-
echo "Version: $VERSION"
49-
50-
# Check if version contains prerelease identifiers
51-
if [[ "$VERSION" =~ -([a-zA-Z]+) ]]; then
52-
DIST_TAG="${BASH_REMATCH[1]}"
53-
echo "Detected prerelease tag: $DIST_TAG"
54-
echo "tag=$DIST_TAG" >> $GITHUB_OUTPUT
55-
else
56-
echo "Detected stable release, using 'latest' tag"
57-
echo "tag=latest" >> $GITHUB_OUTPUT
58-
fi
5946

6047
- name: Publish to npm
6148
run: npm publish --access public --tag ${{ steps.distTag.outputs.tag }}

.github/workflows/onRelease.yml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,25 @@ on:
1010
description: tag that needs to publish
1111
type: string
1212
required: true
13+
1314
jobs:
1415
# parses the package.json version and detects prerelease tag (ex: beta from 4.4.4-beta.0)
1516
getDistTag:
1617
outputs:
1718
tag: ${{ steps.distTag.outputs.tag }}
18-
branch: ${{ steps.getBranch.outputs.branch }}
1919
runs-on: ubuntu-latest
2020
steps:
2121
- uses: actions/checkout@v4
2222
with:
23-
ref: ${{ github.event.release.tag_name || inputs.tag }}
23+
ref: ${{ github.event.release.tag_name || inputs.tag }}
2424
- uses: salesforcecli/github-workflows/.github/actions/getPreReleaseTag@main
2525
id: distTag
26-
- name: Determine branch
27-
id: getBranch
28-
run: |
29-
if [[ "${{ github.event_name }}" == "release" ]]; then
30-
# For release events, use the target branch of the release
31-
BRANCH="${{ github.event.release.target_commitish }}"
32-
else
33-
# For workflow_dispatch, use the current branch
34-
BRANCH="${{ github.ref_name }}"
35-
fi
36-
37-
# Use main if triggered from main, otherwise use prerelease/dev
38-
if [[ "$BRANCH" == "main" ]]; then
39-
echo "branch=main" >> $GITHUB_OUTPUT
40-
else
41-
echo "branch=prerelease/dev" >> $GITHUB_OUTPUT
42-
fi
43-
echo "Detected branch: $BRANCH, using: $(cat $GITHUB_OUTPUT | grep branch | cut -d'=' -f2)"
4426

4527
npm-publish:
4628
if: ${{ needs.getDistTag.outputs.tag != '' }}
4729
uses: ./.github/workflows/npm-publish.yml
4830
needs: [getDistTag]
4931
with:
50-
branch: ${{ needs.getDistTag.outputs.branch }}
32+
tag: ${{ needs.getDistTag.outputs.tag }}
5133
nodeVersion: 'lts/*'
5234
secrets: inherit

0 commit comments

Comments
 (0)