-
Notifications
You must be signed in to change notification settings - Fork 12
93 lines (82 loc) · 2.92 KB
/
release.yml
File metadata and controls
93 lines (82 loc) · 2.92 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
# yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json
---
name: Release
on:
workflow_dispatch:
inputs:
version_type:
description: 'Type of version bump'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
jobs:
create-release:
runs-on: ubuntu-latest
name: Create release
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout sources
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install node 24
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- name: Configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Update package with new version
id: bump
run: |
# Get base version (remove -ea suffix if present, handles both -ea. and -ea- formats)
BASE_VERSION=$(node -p "require('./package.json').version" | sed -E 's/-ea[.-][0-9]+$//')
# Bump the version
NEW_VERSION=$(npm version ${{ inputs.version_type }} --no-git-tag-version | sed 's/v//')
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
- name: Install latest npm
run: npm install -g npm@11.11.1
- name: Install project modules
run: npm ci
- name: Create release branch
run: |
BRANCH="release/v${{ steps.bump.outputs.version }}"
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git checkout -b "$BRANCH"
git add package.json
git add package-lock.json
git commit -m "build: release ${{ steps.bump.outputs.version }} [skip ci]"
git push origin "$BRANCH"
echo "$BRANCH" > releasebranch.txt
- uses: actions/upload-artifact@v7
with:
name: releasebranch.txt
path: releasebranch.txt
- name: Create GitHub release tag
uses: softprops/action-gh-release@v2
with:
name: "Release ${{ steps.bump.outputs.version }}"
tag_name: "v${{ steps.bump.outputs.version }}"
target_commitish: "release/v${{ steps.bump.outputs.version }}"
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Pull Request for release + next version
run: |
gh pr create \
--title "build: release ${{ steps.bump.outputs.version }} [skip ci]" \
--body "build: release ${{ steps.bump.outputs.version }} [skip ci]" \
--base main \
--head "release/v${{ steps.bump.outputs.version }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}