-
-
Notifications
You must be signed in to change notification settings - Fork 2
182 lines (157 loc) · 5.89 KB
/
create-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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Create Release
permissions:
contents: write
pull-requests: read
issues: read
repository-projects: read
actions: write
on:
workflow_dispatch:
inputs:
version:
description: 'Version for the release (e.g., 1.1.0)'
required: true
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
cache: true
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Get Merged PR Details
id: changelog
run: |
# Get changes since last release
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
START_DATE="2024-01-01"
else
START_DATE=$(git log -1 --format=%ai $LAST_TAG)
fi
# Get PRs merged since last release using GitHub CLI
CHANGES=$(gh api graphql -f query='
query($repo:String!, $owner:String!) {
repository(owner: $owner, name: $repo) {
pullRequests(first: 100, states: MERGED, orderBy: {field: UPDATED_AT, direction: DESC}) {
nodes {
title
number
author {
login
}
mergedAt
}
}
}
}
' -F owner="${{ github.repository_owner }}" -F repo="${{ github.event.repository.name }}" | \
jq -r --arg date "$START_DATE" '.data.repository.pullRequests.nodes[] | select(.mergedAt > $date) | "* " + .title + " (#" + (.number|tostring) + ") by @" + .author.login')
echo "changes<<EOF" >> $GITHUB_ENV
echo "$CHANGES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
# Get contributors
CONTRIBUTORS=$(gh api graphql -f query='
query($repo:String!, $owner:String!) {
repository(owner: $owner, name: $repo) {
pullRequests(first: 100, states: MERGED, orderBy: {field: UPDATED_AT, direction: DESC}) {
nodes {
author {
login
}
mergedAt
}
}
}
}
' -F owner="${{ github.repository_owner }}" -F repo="${{ github.event.repository.name }}" | \
jq -r --arg date "$START_DATE" '.data.repository.pullRequests.nodes[] | select(.mergedAt > $date) | .author.login' | sort -u)
echo "new_contributors<<EOF" >> $GITHUB_ENV
echo "$CONTRIBUTORS" | while read -r user; do
echo "* [@$user](https://github.com/$user)"
done
echo "EOF" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev gcc libgtk-3-dev pkg-config
- name: Setup Wails Dependencies
run: |
mkdir -p ../github
cd ../github
git clone https://github.com/ansxuman/wails.git
cd wails
git checkout start_on_login
cd v3/cmd/wails3
go install
cd ../../../..
- name: Update go.mod
run: |
sed -i 's|=> ../wails/v3|=> ../github/wails/v3|g' go.mod
- name: Update Version in Config
run: |
# Configure git
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Strip the 'v' prefix if it exists
VERSION="${{ github.event.inputs.version }}"
CLEAN_VERSION="${VERSION#v}"
# Update AppVersion in CommmonVariables.go
sed -i "s/const AppVersion = .*/const AppVersion = \"$CLEAN_VERSION\"/" constants/CommmonVariables.go
# Update version in config.yml (specifically in the info section)
sed -i "/^info:/,/^[^ ]/ s/ version: .*/ version: \"$CLEAN_VERSION\"/" build/config.yml
# Update build assets
wails3 task common:update:build-assets
# Commit changes excluding go.mod and go.sum
git add .
git reset go.mod go.sum
git commit -m "chore: update version to $CLEAN_VERSION"
git push origin main
- name: Create and Push Tag
run: |
git tag -a "v${{ github.event.inputs.version }}" -m "Release v${{ github.event.inputs.version }}"
git push origin "v${{ github.event.inputs.version }}"
- name: Create Release
id: create-release
uses: actions/create-release@v1
with:
tag_name: "v${{ github.event.inputs.version }}"
release_name: "Clave v${{ github.event.inputs.version }}"
body: |
## 🚀 What's Changed
${{ env.changes}}
## 👥 New Contributors
${{ env.new_contributors}}
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger Build Workflow
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'build-release.yml',
ref: 'main',
inputs: {
release_url: '${{ steps.create-release.outputs.upload_url }}',
version: 'v${{ github.event.inputs.version }}'
}
})