Skip to content

Commit 7ba1c56

Browse files
authored
Merge pull request #51 from jonrebm/release-workflow
CI: Add release workflow
2 parents 84d6c97 + 95f4e35 commit 7ba1c56

File tree

5 files changed

+105
-3
lines changed

5 files changed

+105
-3
lines changed

.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:

.github/workflows/release-pr.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Draft Release
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, closed]
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+
if: >
17+
!(github.event.pull_request.merged == true &&
18+
!contains(join(github.event.pull_request.labels.*.name), 'release'))
19+
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout merge
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Get release commit info
29+
id: version
30+
run: |
31+
ver=$(cat VERSION)
32+
if ! echo "$ver" | grep -Eq '^[0-9]{4}\.[0-9]{2}\.[0-9]+$'; then
33+
echo "Invalid version format: $ver"
34+
exit 1
35+
fi
36+
37+
echo "version=$ver" >> $GITHUB_OUTPUT
38+
39+
headline="$(git show --format=%s ${{github.event.pull_request.head.sha}})"
40+
if ! echo "$headline" | grep -Eq "^[Rr]elease microcom $ver$"; then
41+
echo "Invalid commit headline: $headline"
42+
exit 1
43+
fi
44+
45+
body="$(
46+
git show -s --format=%b ${{github.event.pull_request.head.sha}} \
47+
| sed -E '/^Signed-off-by: /d'
48+
)"
49+
50+
echo 'body<<EOF' >> $GITHUB_OUTPUT
51+
echo "$body" >> $GITHUB_OUTPUT
52+
echo 'EOF' >> $GITHUB_OUTPUT
53+
54+
- name: Install Dependencies
55+
run: sudo apt install -y libreadline6-dev autoconf automake
56+
57+
- name: Build release packages
58+
run: |
59+
autoreconf -i
60+
./configure
61+
make check
62+
make dist
63+
64+
# DRAFT release on pr creation and update
65+
- name: Create or update release draft
66+
if: github.event.pull_request.merged == false
67+
uses: softprops/action-gh-release@v2
68+
with:
69+
draft: true
70+
tag_name: v${{steps.version.outputs.version}}
71+
name: microcom ${{steps.version.outputs.version}}
72+
body: ${{steps.version.outputs.body}}
73+
files: |
74+
microcom-*.tar.gz
75+
microcom-*.tar.xz
76+
77+
# PUBLISH release on merge
78+
- name: Publish release on merge
79+
if: github.event.pull_request.merged == true
80+
uses: softprops/action-gh-release@v2
81+
with:
82+
draft: false
83+
tag_name: v${{steps.version.outputs.version}}
84+
files: |
85+
microcom-*.tar.gz
86+
microcom-*.tar.xz
87+
88+
- run: gh pr edit "$NUMBER" --add-label "$LABELS"
89+
if: github.event.pull_request.merged == false
90+
env:
91+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
92+
GH_REPO: ${{github.repository}}
93+
NUMBER: ${{github.event.pull_request.number}}
94+
LABELS: release
95+
96+
- run: gh pr comment "$NUMBER" --body "Release published!"
97+
if: github.event.pull_request.merged == true
98+
env:
99+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
100+
GH_REPO: ${{github.repository}}
101+
NUMBER: ${{github.event.pull_request.number}}
102+
LABELS: release

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
AUTOMAKE_OPTIONS = foreign
22
ACLOCAL_AMFLAGS = -I m4 --install
33

4-
EXTRA_DIST = DCO README.md
4+
EXTRA_DIST = COPYING DCO README.md VERSION
55

66
bin_PROGRAMS = microcom
77
microcom_SOURCES = commands.c commands_fsl_imx.c microcom.c mux.c parser.c serial.c telnet.c

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)