Skip to content

Commit

Permalink
feat: auto-incrementing beta versions
Browse files Browse the repository at this point in the history
  • Loading branch information
tazarov committed May 7, 2024
1 parent ca69660 commit b081f51
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,39 @@ jobs:
with:
node-version: '18'
registry-url: 'https://npm.pkg.github.com'
- name: Create Beta Tag
id: tag
run: |
set -e
# Get current version
current_version=$(node -p "require('./package.json').version")
# Generate a beta tag using GitHub run number
beta_tag="beta.${GITHUB_RUN_NUMBER}"
# Create full version with beta tag
base_version=$(echo $current_version | cut -f1,2 -d.)
patch_version=$(echo $current_version | cut -f3 -d.)
new_patch_version=$((patch_version + 1))
new_version="${current_version}-${beta_tag}"
new_version="${base_version}.${new_patch_version}-${beta_tag}"
# Create an annotated tag
git tag -a "$new_version" -m "Release version $new_version"
# Set output for later steps
echo "::set-output name=tag_name::$new_version"
- name: Push Beta Tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin "${{ steps.tag.outputs.tag_name }}"
- name: Configure .npmrc
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
- name: Install Dependencies
run: npm install
- name: Publish Package
run: npm publish
run: npm publish --tag "${{ steps.tag.outputs.tag_name }}"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit b081f51

Please sign in to comment.