-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (81 loc) · 2.8 KB
/
release-beta.yml
File metadata and controls
94 lines (81 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Release Beta
on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
default: 'prerelease'
type: choice
options:
- prerelease
- prepatch
- preminor
- premajor
prerelease_id:
description: 'Prerelease identifier (e.g., "beta", "alpha")'
required: false
type: string
default: 'beta'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Upgrade npm for Trusted Publishers
run: npm install -g npm@latest
- name: Install dependencies
run: npm ci
- name: Configure git
run: |
git config --local user.email "${{ secrets.GIT_USER_EMAIL }}"
git config --local user.name "${{ secrets.GIT_USER_NAME }}"
- name: Bump version and push
id: version
run: |
npm version ${{ github.event.inputs.version_type }} --preid=${{ github.event.inputs.prerelease_id }} --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "new_version=v$NEW_VERSION" >> $GITHUB_OUTPUT
git add package.json
git commit -m "🔖 v$NEW_VERSION"
git push origin main
git tag "v$NEW_VERSION"
git push origin "v$NEW_VERSION"
- name: Generate release notes
id: release_notes
run: |
LAST_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
COMMITS=$(git log $LAST_TAG..HEAD --oneline --pretty=format:"- %s")
else
COMMITS=$(git log --oneline --pretty=format:"- %s" | head -10)
fi
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "## What's Changed" >> $GITHUB_OUTPUT
echo "$COMMITS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.new_version }}
release_name: 🧪 ${{ steps.version.outputs.new_version }}
body: ${{ steps.release_notes.outputs.notes }}
draft: false
prerelease: true
- name: Publish to NPM
run: npm publish --provenance --access public --tag ${{ github.event.inputs.prerelease_id }}