|
| 1 | +name: Automated release |
| 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 'llvm_release_' \ |
| 25 | + | sed -E 's/.*\/llvm_release_([0-9]+)/\1/' \ |
| 26 | + | sort -n -r \ |
| 27 | + | head -1 \ |
| 28 | + | xargs printf "latest_branch=llvm_release_%s" \ |
| 29 | + >> $GITHUB_OUTPUT |
| 30 | + - name: Get branch list |
| 31 | + id: release_branches |
| 32 | + run: | |
| 33 | + git branch -r \ |
| 34 | + | grep "origin/llvm_release_" \ |
| 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 | +
|
| 60 | + echo "llvm_version=$LLVM_VERSION" >> $GITHUB_OUTPUT |
| 61 | + echo "patch=$PATCH" >> $GITHUB_OUTPUT |
| 62 | + echo "latest_version=${LATEST_VERSION}" >> $GITHUB_OUTPUT |
| 63 | + echo "release_version=${LLVM_VERSION}.$((${PATCH}+1))" \ |
| 64 | + >> $GITHUB_OUTPUT |
| 65 | +
|
| 66 | + git rev-list ${LATEST_VERSION}..HEAD --count \ |
| 67 | + | xargs printf "commits_since_last_release=%d\n" >> $GITHUB_OUTPUT |
| 68 | + git rev-parse HEAD | xargs printf "last_commit=%s\n" >> $GITHUB_OUTPUT |
| 69 | + - name: Release |
| 70 | + uses: softprops/action-gh-release@v2 |
| 71 | + if: ${{ steps.versions.outputs.commits_since_last_release != 0 }} |
| 72 | + with: |
| 73 | + # Setting tag to have format: |
| 74 | + # %latest llvm version%.%latest patch + 1% |
| 75 | + tag_name: ${{ steps.versions.outputs.release_version }} |
| 76 | + # We have to set this so tag is set on the branch we are releasing |
| 77 | + target_commitish: ${{ steps.versions.outputs.last_commit }} |
| 78 | + # We don't want to mark patch releases latest unless it is latest |
| 79 | + # major version |
| 80 | + make_latest: >- |
| 81 | + ${{ needs.setup.outputs.latest_branch == matrix.branch }} |
| 82 | + name: > |
| 83 | + SPIR-V LLVM translator based on LLVM |
| 84 | + ${{ steps.versions.outputs.llvm_version }} |
| 85 | + body: "Full Changelog: ${{ github.server_url }}/\ |
| 86 | + ${{ github.repository }}/compare/\ |
| 87 | + ${{ steps.versions.outputs.latest_version }}...\ |
| 88 | + ${{ steps.versions.outputs.release_version }}" |
0 commit comments