File: patch-release.yml

package info (click to toggle)
opencl-clang-21 21.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 356 kB
  • sloc: cpp: 1,242; ansic: 47; makefile: 19; sh: 10
file content (121 lines) | stat: -rw-r--r-- 5,035 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Generate patch releases

permissions:
  contents: read

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@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
        with:
            fetch-depth: 0
      - name: Get latest llvm_release branch
        id: latest_branch
        run: |
          git branch -r \
          | grep 'ocl-open-' \
          | sed -E 's/.*\/ocl-open-([0-9]+)/\1/' \
          | sort -n -r \
          | head -1 \
          | xargs printf "latest_branch=ocl-open-%s" \
          >> $GITHUB_OUTPUT
      - name: Get branch list
        id: release_branches
        run: |
          git branch -r \
          | grep "origin/ocl-open-" \
          | sed -E 's/\ *origin\/([^\ ]*)/\"\1\"/' \
          | paste -sd',' \
          | xargs -0 -d"\n" printf 'branches_json={"branch":[%s]}' \
          >> $GITHUB_OUTPUT
  release:
    permissions:
      # required by softprops/action-gh-release to create a release
      contents: write
    runs-on: ubuntu-latest
    needs: setup
    strategy:
      matrix: ${{fromJson(needs.setup.outputs.branches_json)}}
    steps:
      - name: Checkout
        uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
        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: Get SPIRV-LLVM-Translator and llvm-project latest tags
        id: llvm-spirv-versions
        run: |
          export SPIRV_PATCH=\
          $(git ls-remote --tags \
          "https://github.com/KhronosGroup/SPIRV-LLVM-Translator" \
          "refs/tags/v${{ steps.versions.outputs.llvm_version }}.[0-9]" \
          "refs/tags/v${{ steps.versions.outputs.llvm_version }}.[0-9][0-9]" \
          | awk '{print $2}' \
          | sed -E 's/refs\/tags\/v${{ steps.versions.outputs.llvm_version }}.([0-9]+)/\1/' \
          | sort -n \
          | tail -1)
          echo "spirv_patch=${SPIRV_PATCH}" >> $GITHUB_OUTPUT
          export LLVM_PATCH=\
          $(git ls-remote --tags \
          "https://github.com/llvm/llvm-project" \
          "refs/tags/llvmorg-${{ steps.versions.outputs.llvm_version }}.[0-9]" \
          "refs/tags/llvmorg-${{ steps.versions.outputs.llvm_version }}.[0-9][0-9]" \
          | awk '{print $2}' \
          | sed -E 's/refs\/tags\/llvmorg-${{ steps.versions.outputs.llvm_version }}.([0-9]+)/\1/' \
          | sort -n \
          | tail -1)
          echo "llvm_patch=${LLVM_PATCH}" >> $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: v${{ 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: >
              opencl-clang linked against LLVM 
              v${{ steps.versions.outputs.llvm_version }}
              libraries
            # TODO: update
            body: "This release is linked against LLVM \
              v${{ steps.versions.outputs.llvm_version }}.${{ steps.llvm-spirv-versions.outputs.llvm_patch }} \
              and SPIR-V LLVM translator \
              v${{ steps.versions.outputs.llvm_version }}.${{ steps.llvm-spirv-versions.outputs.spirv_patch }}. \
              Full Changelog: ${{ github.server_url }}/\
              ${{ github.repository }}/compare/\
              ${{ steps.versions.outputs.latest_version }}...\
              v${{ steps.versions.outputs.release_version }}"