1+ name : Beta Release
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ beta_type :
7+ description : ' Beta release type'
8+ required : true
9+ default : ' beta'
10+ type : choice
11+ options :
12+ - beta
13+ - alpha
14+ - rc
15+ version_bump :
16+ description : ' Version bump for beta'
17+ required : true
18+ default : ' prerelease'
19+ type : choice
20+ options :
21+ - prerelease
22+ - prepatch
23+ - preminor
24+ - premajor
25+ custom_version :
26+ description : ' Custom version (optional, e.g., 1.0.0-beta.1)'
27+ required : false
28+ type : string
29+
30+ permissions :
31+ contents : write
32+ packages : write
33+ id-token : write
34+
35+ jobs :
36+ beta-release :
37+ name : Beta Release & Publish
38+ runs-on : ubuntu-latest
39+
40+ steps :
41+ - name : Checkout code
42+ uses : actions/checkout@v4
43+ with :
44+ fetch-depth : 0
45+ token : ${{ secrets.GITHUB_TOKEN }}
46+
47+ - name : Setup Node.js
48+ uses : actions/setup-node@v4
49+ with :
50+ node-version : ' 20.x'
51+ registry-url : ' https://registry.npmjs.org'
52+
53+ - name : Cache node_modules
54+ uses : actions/cache@v4
55+ id : npm-cache
56+ with :
57+ path : node_modules
58+ key : ${{ runner.os }}-node-20.x-${{ hashFiles('**/package-lock.json') }}
59+ restore-keys : |
60+ ${{ runner.os }}-node-20.x-
61+
62+ - name : Install dependencies
63+ if : steps.npm-cache.outputs.cache-hit != 'true'
64+ run : npm ci
65+
66+ - name : Configure Git
67+ run : |
68+ git config user.name "github-actions[bot]"
69+ git config user.email "github-actions[bot]@users.noreply.github.com"
70+
71+ - name : Run quality checks
72+ run : |
73+ npm run lint
74+ npm run type-check
75+ npm test
76+
77+ - name : Build library
78+ run : npm run build
79+
80+ - name : Determine beta version
81+ id : version
82+ run : |
83+ CURRENT_VERSION=$(node -p "require('./package.json').version")
84+ echo "Current version: $CURRENT_VERSION"
85+
86+ if [ -n "${{ github.event.inputs.custom_version }}" ]; then
87+ NEW_VERSION="${{ github.event.inputs.custom_version }}"
88+ npm version $NEW_VERSION --no-git-tag-version --allow-same-version
89+ else
90+ # Use npm version with preid
91+ case "${{ github.event.inputs.version_bump }}" in
92+ prerelease)
93+ npm version prerelease --preid=${{ github.event.inputs.beta_type }} --no-git-tag-version
94+ ;;
95+ prepatch)
96+ npm version prepatch --preid=${{ github.event.inputs.beta_type }} --no-git-tag-version
97+ ;;
98+ preminor)
99+ npm version preminor --preid=${{ github.event.inputs.beta_type }} --no-git-tag-version
100+ ;;
101+ premajor)
102+ npm version premajor --preid=${{ github.event.inputs.beta_type }} --no-git-tag-version
103+ ;;
104+ esac
105+ fi
106+
107+ NEW_VERSION=$(node -p "require('./package.json').version")
108+ echo "New version: $NEW_VERSION"
109+ echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
110+ echo "is_beta=true" >> $GITHUB_OUTPUT
111+
112+ - name : Generate beta changelog entry
113+ run : |
114+ VERSION="${{ steps.version.outputs.new_version }}"
115+ DATE=$(date +%Y-%m-%d)
116+
117+ # Create changelog entry for beta
118+ cat > CHANGELOG_ENTRY.md << EOF
119+ ## v$VERSION - $DATE (Beta Release)
120+
121+ ### 🧪 Beta Changes
122+ EOF
123+
124+ # Add recent commits since last tag
125+ if git describe --tags --abbrev=0 2>/dev/null; then
126+ git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"- %s" >> CHANGELOG_ENTRY.md
127+ else
128+ git log --pretty=format:"- %s" -10 >> CHANGELOG_ENTRY.md
129+ fi
130+
131+ echo "" >> CHANGELOG_ENTRY.md
132+ echo "> ⚠️ **This is a beta release** - use with caution in production environments" >> CHANGELOG_ENTRY.md
133+
134+ # Prepend to CHANGELOG.md
135+ if [ -f CHANGELOG.md ]; then
136+ head -n 2 CHANGELOG.md > CHANGELOG_NEW.md
137+ cat CHANGELOG_ENTRY.md >> CHANGELOG_NEW.md
138+ echo "" >> CHANGELOG_NEW.md
139+ tail -n +3 CHANGELOG.md >> CHANGELOG_NEW.md
140+ mv CHANGELOG_NEW.md CHANGELOG.md
141+ else
142+ echo "# Changelog" > CHANGELOG.md
143+ echo "" >> CHANGELOG.md
144+ cat CHANGELOG_ENTRY.md >> CHANGELOG.md
145+ fi
146+
147+ rm CHANGELOG_ENTRY.md
148+
149+ - name : Commit beta version
150+ run : |
151+ git add package.json CHANGELOG.md
152+ git commit -m "chore(release): v${{ steps.version.outputs.new_version }} [beta] [skip ci]" || echo "No changes to commit"
153+
154+ - name : Create beta tag
155+ run : |
156+ git tag -a v${{ steps.version.outputs.new_version }} -m "Beta Release v${{ steps.version.outputs.new_version }}"
157+
158+ - name : Push beta changes
159+ run : |
160+ git push origin ${{ github.ref_name }} --follow-tags
161+
162+ - name : Publish beta to NPM
163+ run : |
164+ echo "Publishing beta version to NPM..."
165+ npm publish --tag ${{ github.event.inputs.beta_type }} --access public
166+ env :
167+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
168+
169+ - name : Create GitHub Pre-release
170+ uses : softprops/action-gh-release@v2
171+ with :
172+ tag_name : v${{ steps.version.outputs.new_version }}
173+ name : 🧪 Beta Release v${{ steps.version.outputs.new_version }}
174+ body : |
175+ ## 🧪 Beta Release v${{ steps.version.outputs.new_version }}
176+
177+ This is a **beta release** of @nexcraft/forge.
178+
179+ ### Installation
180+ ```bash
181+ npm install @nexcraft/forge@${{ github.event.inputs.beta_type }}
182+ ```
183+
184+ ### ⚠️ Beta Warning
185+ This version may contain experimental features and should be used with caution in production environments.
186+
187+ ### What's Changed
188+ See CHANGELOG.md for detailed changes.
189+
190+ **Full Changelog**: https://github.com/dev-ignis/forge/commits/v${{ steps.version.outputs.new_version }}
191+ draft : false
192+ prerelease : true
193+ files : |
194+ dist/nexcraft-forge.es.js
195+ dist/nexcraft-forge.umd.js
196+ dist/index.d.ts
197+
198+ - name : Summary
199+ run : |
200+ echo "🎉 Beta release completed successfully!"
201+ echo "📦 Version: ${{ steps.version.outputs.new_version }}"
202+ echo "🏷️ NPM Tag: ${{ github.event.inputs.beta_type }}"
203+ echo "📥 Install: npm install @nexcraft/forge@${{ github.event.inputs.beta_type }}"
204+ echo "🔗 Release: https://github.com/dev-ignis/forge/releases/tag/v${{ steps.version.outputs.new_version }}"
0 commit comments