Skip to content

Commit 227eee9

Browse files
authored
Add automatic patch release generation (#551)
Similarly to KhronosGroup/SPIRV-LLVM-Translator#2586 adds automated patch release generation. Examples of releases could be found in my fork: https://github.com/ZzEeKkAa/opencl-clang/releases For the final result look at https://github.com/ZzEeKkAa/opencl-clang/releases/tag/v17.0.5 . On other releases I've been playing around with release message. Fixes #537
1 parent 8b4c2c3 commit 227eee9

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

.github/workflows/patch-release.yml

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Generate patch releases
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# First day of every month
7+
- cron: '0 0 1 * *'
8+
9+
jobs:
10+
setup:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
latest_branch: ${{steps.latest_branch.outputs.latest_branch}}
14+
branches_json: ${{steps.release_branches.outputs.branches_json}}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- name: Get latest llvm_release branch
21+
id: latest_branch
22+
run: |
23+
git branch -r \
24+
| grep 'ocl-open-' \
25+
| sed -E 's/.*\/ocl-open-([0-9]+)/\1/' \
26+
| sort -n -r \
27+
| head -1 \
28+
| xargs printf "latest_branch=ocl-open-%s" \
29+
>> $GITHUB_OUTPUT
30+
- name: Get branch list
31+
id: release_branches
32+
run: |
33+
git branch -r \
34+
| grep "origin/ocl-open-" \
35+
| sed -E 's/\ *origin\/([^\ ]*)/\"\1\"/' \
36+
| paste -sd',' \
37+
| xargs -0 -d"\n" printf 'branches_json={"branch":[%s]}' \
38+
>> $GITHUB_OUTPUT
39+
release:
40+
runs-on: ubuntu-latest
41+
needs: setup
42+
strategy:
43+
matrix: ${{fromJson(needs.setup.outputs.branches_json)}}
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v4
47+
with:
48+
ref: ${{ matrix.branch }}
49+
fetch-depth: 0
50+
- name: Get commits info
51+
id: versions
52+
run: |
53+
export LATEST_VERSION=\
54+
"$(git describe --tags --abbrev=0 --match 'v*')"
55+
export LLVM_VERSION=$(echo $LATEST_VERSION \
56+
| sed -E 's/v([0-9]+\.[0-9]+)\.([0-9]+).*/\1/')
57+
export PATCH=$(echo $LATEST_VERSION \
58+
| sed -E 's/(v[0-9]+\.[0-9]+)\.([0-9]+).*/\2/')
59+
echo "llvm_version=$LLVM_VERSION" >> $GITHUB_OUTPUT
60+
echo "patch=$PATCH" >> $GITHUB_OUTPUT
61+
echo "latest_version=${LATEST_VERSION}" >> $GITHUB_OUTPUT
62+
echo "release_version=${LLVM_VERSION}.$((${PATCH}+1))" \
63+
>> $GITHUB_OUTPUT
64+
git rev-list ${LATEST_VERSION}..HEAD --count \
65+
| xargs printf "commits_since_last_release=%d\n" >> $GITHUB_OUTPUT
66+
git rev-parse HEAD | xargs printf "last_commit=%s\n" >> $GITHUB_OUTPUT
67+
- name: Get SPIRV-LLVM-Translator and llvm-project latest tags
68+
id: llvm-spirv-versions
69+
run: |
70+
export SPIRV_PATCH=\
71+
$(git ls-remote --tags \
72+
"https://github.com/KhronosGroup/SPIRV-LLVM-Translator" \
73+
"refs/tags/v${{ steps.versions.outputs.llvm_version }}.[0-9]" \
74+
"refs/tags/v${{ steps.versions.outputs.llvm_version }}.[0-9][0-9]" \
75+
| awk '{print $2}' \
76+
| sed -E 's/refs\/tags\/v${{ steps.versions.outputs.llvm_version }}.([0-9]+)/\1/' \
77+
| sort -n \
78+
| tail -1)
79+
echo "spirv_patch=${SPIRV_PATCH}" >> $GITHUB_OUTPUT
80+
export LLVM_PATCH=\
81+
$(git ls-remote --tags \
82+
"https://github.com/llvm/llvm-project" \
83+
"refs/tags/llvmorg-${{ steps.versions.outputs.llvm_version }}.[0-9]" \
84+
"refs/tags/llvmorg-${{ steps.versions.outputs.llvm_version }}.[0-9][0-9]" \
85+
| awk '{print $2}' \
86+
| sed -E 's/refs\/tags\/llvmorg-${{ steps.versions.outputs.llvm_version }}.([0-9]+)/\1/' \
87+
| sort -n \
88+
| tail -1)
89+
echo "llvm_patch=${LLVM_PATCH}" >> $GITHUB_OUTPUT
90+
- name: Release
91+
uses: softprops/action-gh-release@v2
92+
if: ${{ steps.versions.outputs.commits_since_last_release != 0 }}
93+
with:
94+
# Setting tag to have format:
95+
# %latest llvm version%.%latest patch + 1%
96+
tag_name: v${{ steps.versions.outputs.release_version }}
97+
# We have to set this so tag is set on the branch we are releasing
98+
target_commitish: ${{ steps.versions.outputs.last_commit }}
99+
# We don't want to mark patch releases latest unless it is latest
100+
# major version
101+
make_latest: >-
102+
${{ needs.setup.outputs.latest_branch == matrix.branch }}
103+
name: >
104+
opencl-clang linked against LLVM
105+
v${{ steps.versions.outputs.llvm_version }}
106+
libraries
107+
# TODO: update
108+
body: "This release is linked against LLVM \
109+
v${{ steps.versions.outputs.llvm_version }}.${{ steps.llvm-spirv-versions.outputs.llvm_patch }} \
110+
and SPIR-V LLVM translator \
111+
v${{ steps.versions.outputs.llvm_version }}.${{ steps.llvm-spirv-versions.outputs.spirv_patch }}. \
112+
Full Changelog: ${{ github.server_url }}/\
113+
${{ github.repository }}/compare/\
114+
${{ steps.versions.outputs.latest_version }}...\
115+
v${{ steps.versions.outputs.release_version }}"

0 commit comments

Comments
 (0)