Skip to content

Commit 5fc0aea

Browse files
committed
feat: ability to create automated alpha & beta releases
1 parent 8a7d4ba commit 5fc0aea

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

.github/workflows/publish.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,30 @@ jobs:
2121
run: yarn build
2222
- name: Get the release tag version
2323
id: get_version
24-
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
24+
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
25+
- name: Extract pre-release tag if any
26+
id: extract_tag
27+
run: |
28+
VERSION="${{ steps.get_version.outputs.VERSION }}"
29+
if [[ $VERSION == *-* ]]; then
30+
# Extract everything between hyphen and last period (or end of string)
31+
PRETAG=$(echo $VERSION | sed -E 's/.*-([^.]+).*/\1/')
32+
echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT
33+
echo "NPM_TAG=$PRETAG" >> $GITHUB_OUTPUT
34+
else
35+
echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT
36+
echo "NPM_TAG=latest" >> $GITHUB_OUTPUT
37+
fi
38+
- name: Get source branch
39+
id: get_branch
40+
run: |
41+
RELEASE_COMMIT=$(git rev-list -n 1 ${{ steps.get_version.outputs.VERSION }})
42+
SOURCE_BRANCH=$(git branch -r --contains $RELEASE_COMMIT | grep -v HEAD | head -n 1 | sed 's/.*origin\///')
43+
echo "SOURCE_BRANCH=$SOURCE_BRANCH" >> $GITHUB_OUTPUT
2544
- name: Set package version
2645
run: yarn version --new-version "${{ steps.get_version.outputs.VERSION }}" --no-git-tag-version
2746
- name: Publish package
28-
run: yarn publish --access public
47+
run: yarn publish --access public --tag ${{ steps.extract_tag.outputs.NPM_TAG }}
2948
env:
3049
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3150
- name: Push version bump

0 commit comments

Comments
 (0)