-
Notifications
You must be signed in to change notification settings - Fork 0
211 lines (174 loc) 路 6.46 KB
/
Copy pathrelease.yml
File metadata and controls
211 lines (174 loc) 路 6.46 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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: Release Frontend
on:
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g. v1.0.0)"
required: true
title:
description: "Release title (e.g. Release v1.0.0)"
required: false
default: ""
previous_tag:
description: "Previous tag for changelog comparison (leave empty to auto-detect)"
required: false
default: ""
pre_release:
description: "Mark as pre-release"
required: false
default: "false"
type: boolean
draft:
description: "Create as draft"
required: false
default: "false"
type: boolean
permissions:
contents: write
jobs:
prepare-release:
name: Prepare Release
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.config.outputs.tag }}
title: ${{ steps.config.outputs.title }}
previous_tag: ${{ steps.changelog.outputs.previous_tag }}
is_pre_release: ${{ steps.config.outputs.is_pre_release }}
is_draft: ${{ steps.config.outputs.is_draft }}
commit_sha: ${{ steps.config.outputs.commit_sha }}
contributors: ${{ steps.changelog.outputs.contributors }}
whats_changed: ${{ steps.changelog.outputs.changes }}
steps:
- name: Check out Git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Release Parameters
id: config
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG="${GITHUB_REF#refs/tags/}"
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
if [ -n "${{ github.event.inputs.title }}" ]; then
echo "title=${{ github.event.inputs.title }}" >> $GITHUB_OUTPUT
else
echo "title=Release $TAG" >> $GITHUB_OUTPUT
fi
if [ "${{ github.event.inputs.pre_release }}" = "true" ]; then
echo "is_pre_release=true" >> $GITHUB_OUTPUT
elif [[ "$TAG" =~ -(alpha|beta|rc|pre|preview) ]]; then
echo "is_pre_release=true" >> $GITHUB_OUTPUT
else
echo "is_pre_release=false" >> $GITHUB_OUTPUT
fi
echo "is_draft=${{ github.event.inputs.draft }}" >> $GITHUB_OUTPUT
echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Generate Changelog
id: changelog
shell: bash
run: |
CURRENT_TAG="${{ steps.config.outputs.tag }}"
INPUT_PREV="${{ github.event.inputs.previous_tag }}"
if [ -n "$INPUT_PREV" ]; then
PREV_TAG="$INPUT_PREV"
else
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
fi
echo "Current: $CURRENT_TAG, Previous: $PREV_TAG"
echo "previous_tag=$PREV_TAG" >> $GITHUB_OUTPUT
if [ -z "$PREV_TAG" ]; then
echo "No previous tag found. Listing all commits."
COMMITS=$(git log --pretty=format:"- %s (@**%an**)" --reverse)
CONTRIBUTORS=$(git log --pretty=format:"%an" | sort | uniq -c | sort -nr | awk '{print "- **" $2 "** (" $1 " commits)"}')
else
echo "Generating changelog from $PREV_TAG to HEAD."
COMMITS=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s (@%an)" --reverse)
CONTRIBUTORS=$(git log ${PREV_TAG}..HEAD --pretty=format:"%an" | sort | uniq -c | sort -nr | awk '{print "- " $2 " (" $1 " commits)"}')
fi
if [ -z "$COMMITS" ]; then COMMITS="No visible changes."; fi
if [ -z "$CONTRIBUTORS" ]; then CONTRIBUTORS="No new contributors."; fi
{
echo "changes<<EOF"
echo "$COMMITS"
echo "EOF"
} >> $GITHUB_OUTPUT
{
echo "contributors<<EOF"
echo "$CONTRIBUTORS"
echo "EOF"
} >> $GITHUB_OUTPUT
build:
name: Build Frontend
runs-on: ubuntu-latest
needs: prepare-release
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Configure Production Environment
run: |
echo "VITE_API_BASE_URL=/api" > .env.production
echo "Created .env.production with VITE_API_BASE_URL=/api"
- name: Build Project
run: pnpm build
- name: Compress Assets
shell: bash
run: |
TAG_NAME="${{ needs.prepare-release.outputs.tag }}"
ARCHIVE_NAME="open-profile-card-${TAG_NAME}.zip"
mkdir -p ./artifacts
cd dist
zip -r ../artifacts/$ARCHIVE_NAME .
cd ..
echo "Build Complete: $ARCHIVE_NAME"
ls -lh ./artifacts/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: open-profile-card-release
path: ./artifacts/*
retention-days: 1
create-release:
name: Create Release
runs-on: ubuntu-latest
needs: [prepare-release, build]
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Display Artifacts structure
run: ls -R ./artifacts
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare-release.outputs.tag }}
name: ${{ needs.prepare-release.outputs.title }}
target_commitish: ${{ needs.prepare-release.outputs.commit_sha }}
draft: ${{ needs.prepare-release.outputs.is_draft }}
prerelease: ${{ needs.prepare-release.outputs.is_pre_release }}
generate_release_notes: false
body: |
## What's Changed
${{ needs.prepare-release.outputs.whats_changed }}
## Contributors
${{ needs.prepare-release.outputs.contributors }}
---
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ needs.prepare-release.outputs.previous_tag }}...${{ needs.prepare-release.outputs.tag }}
files: ./artifacts/**/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}