Skip to content

Commit 2f6aaa9

Browse files
authored
ci release: publish GitHub Releases by pushing a tag (#48)
1 parent 761886b commit 2f6aaa9

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed

.github/workflows/release.yaml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Copyright (C) 2025 Sutou Kouhei <[email protected]>
2+
#
3+
# This library is free software: you can redistribute it and/or modify
4+
# it under the terms of the GNU Lesser General Public License as published by
5+
# the Free Software Foundation, either version 3 of the License, or
6+
# (at your option) any later version.
7+
#
8+
# This library is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU Lesser General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU Lesser General Public License
14+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+
name: Release
17+
on:
18+
push:
19+
paths:
20+
- '.github/workflows/release.yaml'
21+
- 'NEWS.md'
22+
branches:
23+
- "*"
24+
tags:
25+
- "*"
26+
pull_request:
27+
paths:
28+
- '.github/workflows/release.yaml'
29+
- 'NEWS.md'
30+
jobs:
31+
publish:
32+
name: Publish
33+
runs-on: ubuntu-latest
34+
environment: release
35+
env:
36+
CCACHE_DIR: ${{ github.workspace }}/cache
37+
steps:
38+
- uses: actions/checkout@v5
39+
with:
40+
fetch-depth: 0
41+
- name: Install dependencies
42+
run: |
43+
sudo apt update
44+
sudo apt install -y -V \
45+
ccache \
46+
g++ \
47+
gtk-doc-tools \
48+
imagemagick \
49+
inkscape \
50+
intltool \
51+
libglib2.0-dev \
52+
libsoup2.4-dev \
53+
libtool \
54+
make \
55+
rdtool \
56+
ruby-fast-gettext
57+
- uses: actions/cache@v4
58+
with:
59+
path: cache
60+
key: release-${{ hashFiles('*cutter/**') }}
61+
restore-keys: release-
62+
- name: Prepare
63+
run: |
64+
version_major=$(grep -F '[cutter_version_major]' configure.ac | grep -o '[0-9]*' | tail -n1)
65+
version_minor=$(grep -F '[cutter_version_minor]' configure.ac | grep -o '[0-9]*' | tail -n1)
66+
version_micro=$(grep -F '[cutter_version_micro]' configure.ac | grep -o '[0-9]*' | tail -n1)
67+
echo "VERSION=${version_major}.${version_minor}.${version_micro}" >> "${GITHUB_ENV}"
68+
- name: Autogen
69+
run: |
70+
./autogen.sh
71+
- name: Configure
72+
run: |
73+
./configure PATH=/usr/lib/ccache:$PATH
74+
- name: Build source archive
75+
run: |
76+
make -j$(nproc)
77+
make dist
78+
sha256sum cutter-${VERSION}.tar.gz > cutter-${VERSION}.tar.gz.sha256
79+
- name: Generate release note
80+
env:
81+
GH_TOKEN: ${{ github.token }}
82+
run: |
83+
set -o pipefail
84+
85+
ruby \
86+
-e 'print("## Cutter "); \
87+
puts(ARGF.read.split(/^## /)[1]. \
88+
gsub(/\[(.+?)\]\[.+?\]/) {$1})' \
89+
NEWS.md | tee release-note.md
90+
91+
previous_tag=$(gh release list \
92+
--jq '.[].tagName' \
93+
--json tagName \
94+
--limit 1)
95+
96+
echo | tee -a release-note.md
97+
echo "### Contributors" | tee -a release-note.md
98+
echo | tee -a release-note.md
99+
command_line="git shortlog -sn ${previous_tag}.."
100+
echo '```console' | tee -a release-note.md
101+
echo "\$ ${command_line}" | tee -a release-note.md
102+
${command_line} | tee -a release-note.md
103+
echo '```' | tee -a release-note.md
104+
- name: Publish release page
105+
if: |
106+
github.ref_type == 'tag'
107+
env:
108+
GH_TOKEN: ${{ github.token }}
109+
run: |
110+
title="$(head -n1 release-note.md | sed -e 's/^## //')"
111+
tail -n +2 release-note.md > release-note-without-version.md
112+
gh release create "${GITHUB_REF_NAME}" \
113+
--discussion-category Announcements \
114+
--notes-file release-note-without-version.md \
115+
--title "${title}" \
116+
cutter-${VERSION}.tar.gz*

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# NEWS
2+
3+
## 1.2.9: 2025-10-24
4+
5+
### Improvements
6+
7+
* Use GitHub Releases for the official source archive distribute
8+
location.

0 commit comments

Comments
 (0)