-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (71 loc) · 2.42 KB
/
public-release.yml
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
name: Nightly Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
release_type:
description: 'Release type (major, minor, patch)'
required: true
default: 'patch'
# https://docs.github.com/en/actions/learn-github-actions/variables
env:
HUSKY: 0
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20' # Use Node.js 16 or later
- name: Install dependencies
run: npm install
- name: Commit any changes made during setup
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "chore: commit changes made during setup"
git push
fi
env:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
- name: Determine version bump
id: determine_version
run: |
case "${{ github.event.inputs.release_type }}" in
major) VERSION_BUMP="major" ;;
minor) VERSION_BUMP="minor" ;;
patch) VERSION_BUMP="patch" ;;
*) echo "Invalid release type"; exit 1 ;;
esac
echo "VERSION_BUMP=$VERSION_BUMP" >> $GITHUB_ENV
- name: Bump version, create tag, and push changes
id: bump_version
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
CURRENT_VERSION=$(cat package.json | jq -r ".version")
echo "Current version: $CURRENT_VERSION"
NEW_VERSION=$(npm version $VERSION_BUMP -m "Release version %s [skip ci]")
echo "New version: $NEW_VERSION"
git push --follow-tags
env:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
VERSION_BUMP: ${{ env.VERSION_BUMP }}
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ steps.bump_version.outputs.NEW_VERSION }}
release_name: Release ${{ steps.bump_version.outputs.NEW_VERSION }}
body: "Automated release created for version ${{ steps.bump_version.outputs.NEW_VERSION }}."
draft: false
prerelease: false
env:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}