-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (119 loc) · 4.17 KB
/
Copy pathrelease.yml
File metadata and controls
139 lines (119 loc) · 4.17 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Release (Manual)
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.2.0)'
required: true
type: string
prerelease:
description: 'Is this a pre-release?'
required: false
type: boolean
default: false
permissions:
contents: write
jobs:
create-tag:
name: Create Tag
runs-on: ubuntu-latest
outputs:
tag_name: v${{ inputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Create and push tag
run: |
TAG_NAME="v${{ inputs.version }}"
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Tag $TAG_NAME already exists"
else
git tag -a "$TAG_NAME" -m "Release $TAG_NAME"
git push origin "$TAG_NAME"
fi
build:
name: Build & Release
needs: create-tag
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
ref: v${{ inputs.version }}
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Generate changelog
id: changelog
run: |
TAG_NAME="v${{ inputs.version }}"
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]' | grep -v "$TAG_NAME" | head -1)
if [ -z "$PREV_TAG" ]; then
RANGE="$TAG_NAME"
else
RANGE="${PREV_TAG}..${TAG_NAME}"
fi
echo "Generating changelog for $RANGE"
CHANGELOG=""
add_section() {
local title="$1" prefix="$2"
local entries=$(git log "$RANGE" --pretty=format:"%s" --grep="^${prefix}" | sed "s/^${prefix}[:(][^)]*)[: ]*//" | sed "s/^${prefix}: //" | sed 's/^/- /')
if [ -n "$entries" ]; then
CHANGELOG="${CHANGELOG}### ${title}\n\n${entries}\n\n"
fi
}
add_section "Features" "feat"
add_section "Bug Fixes" "fix"
add_section "Performance" "perf"
add_section "Refactor" "refactor"
add_section "Documentation" "docs"
# Miscellaneous (chore, excluding release/version bumps)
MISC=$(git log "$RANGE" --pretty=format:"%s" --grep="^chore" | grep -v -E "^chore\((release|version)\)" | grep -v "^chore: version" | sed 's/^chore[:(][^)]*)[: ]*//' | sed 's/^chore: //' | sed 's/^/- /')
if [ -n "$MISC" ]; then
CHANGELOG="${CHANGELOG}### Miscellaneous\n\n${MISC}\n\n"
fi
if [ -z "$CHANGELOG" ]; then
CHANGELOG="No notable changes."
fi
# Write to file for multi-line safety
echo -e "$CHANGELOG" > changelog.md
shell: bash
- name: Build and Release
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
tagName: v${{ inputs.version }}
releaseName: 'Ntfier v${{ inputs.version }}'
releaseBody: ''
releaseDraft: true
prerelease: ${{ inputs.prerelease }}
- name: Update release with changelog and update.json
run: |
node scripts/generate-update-json.js
gh release edit "v${{ inputs.version }}" --notes-file changelog.md
gh release upload "v${{ inputs.version }}" update.json --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: v${{ inputs.version }}