Skip to content

Commit e895f5c

Browse files
committed
CI: Add release workflow
This github actions workflow will create a draft release for PRs that updates the version file. The commit message subject line must be Release microcom <version> The commit message body will be used as release description. The release is converted from draft to an actual release, and the commit thereby tagged once the PR is merged. Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
1 parent 84d6c97 commit e895f5c

5 files changed

Lines changed: 110 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
name: Build test
32
on:
43
push:
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
paths:
7+
- VERSION
8+
branches: [main]
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
publish-release:
15+
if: |
16+
github.event.pull_request.merged == true &&
17+
contains(github.event.pull_request.labels.*.name, 'release')
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: Read version from VERSION
24+
id: version
25+
run: |
26+
ver=$(cat VERSION)
27+
echo "version=$ver" >> $GITHUB_OUTPUT
28+
29+
- name: Publish GitHub Release
30+
uses: softprops/action-gh-release@v2
31+
with:
32+
draft: false
33+
tag_name: "v${{ steps.version.outputs.version }}"
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Draft Release
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
paths:
7+
- VERSION
8+
branches: [main]
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
validate-release-commit:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout merge
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Get release commit info
25+
id: version
26+
run: |
27+
ver=$(cat VERSION)
28+
if ! echo "$ver" | grep -Eq '^[0-9]{4}\.[0-9]{2}\.[0-9]+$'; then
29+
echo "Invalid version format: $ver"
30+
exit 1
31+
fi
32+
33+
echo "version=$ver" >> $GITHUB_OUTPUT
34+
35+
headline="$(git show --format=%s ${{github.event.pull_request.head.sha}})"
36+
if ! echo "$headline" | grep -Eq "^[Rr]elease microcom $ver$"; then
37+
echo "Invalid commit headline: $headline"
38+
exit 1
39+
fi
40+
41+
body="$(
42+
git show -s --format=%b ${{github.event.pull_request.head.sha}} \
43+
| sed -E '/^Signed-off-by: /d'
44+
)"
45+
46+
echo 'body<<EOF' >> $GITHUB_OUTPUT
47+
echo "$body" >> $GITHUB_OUTPUT
48+
echo 'EOF' >> $GITHUB_OUTPUT
49+
50+
- name: Install Dependencies
51+
run: sudo apt install -y libreadline6-dev autoconf automake
52+
53+
- name: Build release packages
54+
run: |
55+
autoreconf -i
56+
./configure
57+
make dist
58+
59+
- name: Create or update release draft
60+
uses: softprops/action-gh-release@v2
61+
with:
62+
draft: true
63+
tag_name: v${{steps.version.outputs.version}}
64+
name: microcom ${{steps.version.outputs.version}}
65+
body: ${{steps.version.outputs.body}}
66+
files: |
67+
microcom-*.tar.gz
68+
microcom-*.tar.xz
69+
70+
- run: gh pr edit "$NUMBER" --add-label "$LABELS"
71+
env:
72+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
73+
GH_REPO: ${{github.repository}}
74+
NUMBER: ${{github.event.pull_request.number}}
75+
LABELS: release

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023.09.0

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([microcom], [2023.09.0], [oss-tools@pengutronix.de])
1+
AC_INIT([microcom], [m4_esyscmd_s(cat VERSION)], [oss-tools@pengutronix.de])
22
AC_CONFIG_AUX_DIR([build-aux])
33
AC_CONFIG_MACRO_DIR([m4])
44
AM_INIT_AUTOMAKE([dist-xz])

0 commit comments

Comments
 (0)