Skip to content

Commit 5a83ccd

Browse files
committed
add github release workflow
1 parent d177f1d commit 5a83ccd

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Create GitHub release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Release tagged mainline commit
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check out repository history
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Check whether the tag is on mainline
23+
id: tag-check
24+
env:
25+
TAG_NAME: ${{ github.ref_name }}
26+
shell: bash
27+
run: |
28+
git fetch --no-tags origin mainline
29+
tag_commit="$(git rev-list -n 1 "$TAG_NAME")"
30+
31+
if git merge-base --is-ancestor "$tag_commit" origin/mainline; then
32+
echo "on_mainline=true" >> "$GITHUB_OUTPUT"
33+
else
34+
echo "on_mainline=false" >> "$GITHUB_OUTPUT"
35+
echo "Tag $TAG_NAME does not point to a commit on mainline; skipping release."
36+
fi
37+
38+
- name: Create GitHub release
39+
if: steps.tag-check.outputs.on_mainline == 'true'
40+
env:
41+
GH_TOKEN: ${{ github.token }}
42+
TAG_NAME: ${{ github.ref_name }}
43+
run: gh release create "$TAG_NAME" --verify-tag --generate-notes --title "$TAG_NAME"

0 commit comments

Comments
 (0)