Skip to content

Commit 2460c0a

Browse files
authored
Create release.yml
1 parent 3d79283 commit 2460c0a

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

.github/workflows/release.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.11'
20+
21+
- name: Install Qt
22+
uses: jurplel/install-qt-action@v4
23+
with:
24+
version: '6.8.3'
25+
26+
- name: Build Project with CMake
27+
run: |
28+
mkdir build
29+
cd build
30+
cmake ..
31+
make
32+
33+
- name: Upload build artifact
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: bikram-calendar
37+
path: ./build/bikram-calendar
38+
39+
release:
40+
needs: build
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v4
46+
with:
47+
fetch-depth: 0 # Needed to get full git history for changelog
48+
49+
- name: Generate changelog
50+
id: changelog
51+
run: |
52+
# Current tag that triggered the workflow
53+
CURR_TAG="${GITHUB_REF_NAME}"
54+
55+
if [ "$(git tag --sort=-creatordate | wc -l)" -eq 1 ]; then
56+
# First release
57+
FIRST_COMMIT=$(git rev-list --max-parents=0 HEAD | sort | head -n 1)
58+
LOG=$(git log "$FIRST_COMMIT..$CURR_TAG" --reverse --pretty=format:"- %s (%h)")
59+
else
60+
# Later releases - commits since previous tag
61+
PREV_TAG=$(git tag --sort=-creatordate | sed -n 2p)
62+
LOG=$(git log "$PREV_TAG..$CURR_TAG" --reverse --pretty=format:"- %s (%h)")
63+
fi
64+
65+
# Output to GitHub Actions
66+
{
67+
printf 'LOG<<EOF\n'
68+
printf '%s\n' "$LOG"
69+
printf 'EOF\n'
70+
} >> "$GITHUB_OUTPUT"
71+
72+
- name: Download build artifact
73+
uses: actions/download-artifact@v4
74+
with:
75+
name: bikram-calendar
76+
path: ./build
77+
78+
- name: Create or Update Release
79+
uses: softprops/action-gh-release@v1
80+
with:
81+
files: ./build/bikram-calendar
82+
tag_name: ${{ github.ref_name }}
83+
name: Release ${{ github.ref_name }}
84+
body: |
85+
Changes since last release:
86+
${{ steps.changelog.outputs.LOG }}
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)