forked from triton-lang/triton
-
Notifications
You must be signed in to change notification settings - Fork 7
77 lines (73 loc) · 2.82 KB
/
create_release.yml
File metadata and controls
77 lines (73 loc) · 2.82 KB
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
name: Create Release
on:
push:
branches:
- main
- release/*
tags:
# Final Release tags look like: v1.11.0
- v[0-9]+.[0-9]+.[0-9]+
# Release candidate tags look like: v1.11.0-rc1
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
release:
types: [published]
pull_request:
paths: [.github/workflows/create_release.yml]
jobs:
release:
if: ${{ github.repository == 'triton-lang/triton' }}
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
release_name: "${{ steps.release_name.outputs.name }}"
steps:
- uses: actions/checkout@v4
with:
show-progress: false
submodules: 'recursive'
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
- name: Fake name for PRs
if: ${{ github.event_name == 'pull_request' }}
run: echo "PT_GITHUB_REF=refs/tags/pr-tag" >> "$GITHUB_ENV"
- name: Real name for non-PRs
if: ${{ github.event_name != 'pull_request' }}
run: echo "PT_GITHUB_REF=$GITHUB_REF" >> "$GITHUB_ENV"
- name: Set filenames
run: |
tag_or_branch="${PT_GITHUB_REF#refs/tags/}"
tag_or_branch="${tag_or_branch#refs/heads/}"
# replace directory separators with _ in branch name
tag_or_branch="${tag_or_branch//\//_}"
if [[ ${tag_or_branch} == v* ]]; then
# strip trailing v from tag name
tag_or_branch="${tag_or_branch#v}"
# important: version must be fixed in setup.py
sed -i -e "s:^TRITON_VERSION = .*:TRITON_VERSION = '${tag_or_branch}':" setup.py || exit 1
fi
echo "RELEASE_NAME=triton-$tag_or_branch" >> "$GITHUB_ENV"
- name: Create source distribution
run: |
pip install build || exit 1
python -m build -s || exit 1
cd dist || exit 1
release_file=( *.tar.gz )
echo "RELEASE_FILE=${release_file}" >> "$GITHUB_ENV"
- name: Upload source distribution for release
if: ${{ github.event_name == 'release' }}
uses: softprops/action-gh-release@v2
with:
files: dist/${{env.RELEASE_FILE}}
- name: Upload source distribution to GHA artifacts for release tags
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'rc') }}
uses: actions/upload-artifact@v4.4.0
with:
name: ${{ env.RELEASE_FILE }}
path: dist/${{ env.RELEASE_FILE }}
- name: Set output
id: release_name
run: echo "name=release_name::${{ env.RELEASE_NAME }}.tar.gz" >> "${GITHUB_OUTPUT}"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name }}
cancel-in-progress: true