Skip to content

Commit

Permalink
Add automated release workflow (#2586)
Browse files Browse the repository at this point in the history
Some of the upstream PRs are getting backported to the llvm_release_* branches, but those changes are never released. That prevents them from distributing as precompiled packages in various distributions like conda-forge and others. This PR targets this issue by creating automated workflow that is triggered once a month and generates automated releases for each such branch if there were changes since last release.

This PR
Adds workflow to generate releases every month from llvm_release_* branches in the format %llvm_major%.%llvm_minor%.%latest patch version +1%. For example:
v18.1.1
v17.0.2
v17.0.1
v14.0.1
etc

Release description matches as close as possible to current releases. The only difference is that llvm versions is represented by two numbers, instead of three, because it is impossible to recover exact version. You can check out example of generated versions here (there are few releases from the original proposal): https://github.com/ZzEeKkAa/SPIRV-LLVM-Translator/releases
Workflow is set to be triggered once a month. It is also possible to trigger it manually from github actions UI.

Merge process
Merge the PR to main
Trigger workflow manually

Note
There is no need to backport changes to all branches, since workflow dispatch on schedule basis can be performed only from main branch.

Fixes: #1898
Fixes: #1508

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@63e89a9a268e5c2
  • Loading branch information
ZzEeKkAa authored and sys-ce-bb committed Jun 27, 2024
1 parent eaea1d8 commit ec826c5
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
88 changes: 88 additions & 0 deletions llvm-spirv/.github/workflows/patch-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Automated release

on:
workflow_dispatch:
schedule:
# First day of every month
- cron: '0 0 1 * *'

jobs:
setup:
runs-on: ubuntu-latest
outputs:
latest_branch: ${{steps.latest_branch.outputs.latest_branch}}
branches_json: ${{steps.release_branches.outputs.branches_json}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get latest llvm_release branch
id: latest_branch
run: |
git branch -r \
| grep 'llvm_release_' \
| sed -E 's/.*\/llvm_release_([0-9]+)/\1/' \
| sort -n -r \
| head -1 \
| xargs printf "latest_branch=llvm_release_%s" \
>> $GITHUB_OUTPUT
- name: Get branch list
id: release_branches
run: |
git branch -r \
| grep "origin/llvm_release_" \
| sed -E 's/\ *origin\/([^\ ]*)/\"\1\"/' \
| paste -sd',' \
| xargs -0 -d"\n" printf 'branches_json={"branch":[%s]}' \
>> $GITHUB_OUTPUT
release:
runs-on: ubuntu-latest
needs: setup
strategy:
matrix: ${{fromJson(needs.setup.outputs.branches_json)}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
fetch-depth: 0
- name: Get commits info
id: versions
run: |
export LATEST_VERSION=\
"$(git describe --tags --abbrev=0 --match 'v*')"
export LLVM_VERSION=$(echo $LATEST_VERSION \
| sed -E 's/(v[0-9]+\.[0-9]+)\.([0-9]+).*/\1/')
export PATCH=$(echo $LATEST_VERSION \
| sed -E 's/(v[0-9]+\.[0-9]+)\.([0-9]+).*/\2/')
echo "llvm_version=$LLVM_VERSION" >> $GITHUB_OUTPUT
echo "patch=$PATCH" >> $GITHUB_OUTPUT
echo "latest_version=${LATEST_VERSION}" >> $GITHUB_OUTPUT
echo "release_version=${LLVM_VERSION}.$((${PATCH}+1))" \
>> $GITHUB_OUTPUT
git rev-list ${LATEST_VERSION}..HEAD --count \
| xargs printf "commits_since_last_release=%d\n" >> $GITHUB_OUTPUT
git rev-parse HEAD | xargs printf "last_commit=%s\n" >> $GITHUB_OUTPUT
- name: Release
uses: softprops/action-gh-release@v2
if: ${{ steps.versions.outputs.commits_since_last_release != 0 }}
with:
# Setting tag to have format:
# %latest llvm version%.%latest patch + 1%
tag_name: ${{ steps.versions.outputs.release_version }}
# We have to set this so tag is set on the branch we are releasing
target_commitish: ${{ steps.versions.outputs.last_commit }}
# We don't want to mark patch releases latest unless it is latest
# major version
make_latest: >-
${{ needs.setup.outputs.latest_branch == matrix.branch }}
name: >
SPIR-V LLVM translator based on LLVM
${{ steps.versions.outputs.llvm_version }}
body: "Full Changelog: ${{ github.server_url }}/\
${{ github.repository }}/compare/\
${{ steps.versions.outputs.latest_version }}...\
${{ steps.versions.outputs.release_version }}"
6 changes: 6 additions & 0 deletions llvm-spirv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,9 @@ LLVM/Clang release and there are no objections from the maintainer(s). There
is no guarantee that older release branches are proactively kept up to date
with main, but you can request specific commits on older release branches by
creating a pull request or raising an issue on GitHub.

## Releasing strategy

As mentioned earlier there are branches `llvm_release_*` that get backported
changes. Those changes if exists are released automatically by github CI on
monthly basis in a format `<llvm_major>.<llvm_minor>.<latest patch +1>`.

0 comments on commit ec826c5

Please sign in to comment.