Skip to content

Commit 129fd44

Browse files
authored
Add release workflow to distribute sdist via Release notes (#6332)
This should enable to distribute sdist with Release notes. Tesing: https://github.com/atalman/triton/releases/tag/v3.0.0
1 parent b6db566 commit 129fd44

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release/*
8+
tags:
9+
# Final Release tags look like: v1.11.0
10+
- v[0-9]+.[0-9]+.[0-9]+
11+
# Release candidate tags look like: v1.11.0-rc1
12+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
13+
release:
14+
types: [published]
15+
pull_request:
16+
paths: [.github/workflows/create_release.yml]
17+
18+
jobs:
19+
20+
release:
21+
if: ${{ github.repository == 'triton-lang/triton' }}
22+
name: Create Release
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: write
26+
outputs:
27+
release_name: "${{ steps.release_name.outputs.name }}"
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
show-progress: false
32+
submodules: 'recursive'
33+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
34+
- name: Fake name for PRs
35+
if: ${{ github.event_name == 'pull_request' }}
36+
run: echo "PT_GITHUB_REF=refs/tags/pr-tag" >> "$GITHUB_ENV"
37+
- name: Real name for non-PRs
38+
if: ${{ github.event_name != 'pull_request' }}
39+
run: echo "PT_GITHUB_REF=$GITHUB_REF" >> "$GITHUB_ENV"
40+
- name: Set filenames
41+
run: |
42+
tag_or_branch="${PT_GITHUB_REF#refs/tags/}"
43+
tag_or_branch="${tag_or_branch#refs/heads/}"
44+
# replace directory separators with _ in branch name
45+
tag_or_branch="${tag_or_branch//\//_}"
46+
echo "RELEASE_NAME=triton-$tag_or_branch" >> "$GITHUB_ENV"
47+
echo "RELEASE_FILE=triton-$tag_or_branch.tar.gz" >> "$GITHUB_ENV"
48+
- name: Create source distribution
49+
run: |
50+
# Create new folder with specified name so extracting the archive yields that
51+
rm -rf "/tmp/$RELEASE_NAME"
52+
cp -r "$PWD" "/tmp/$RELEASE_NAME"
53+
mv "/tmp/$RELEASE_NAME" .
54+
# Cleanup
55+
find "$RELEASE_NAME" -name '.git*' -exec rm -rv {} \; || true
56+
# Create archive
57+
tar -czf "$RELEASE_FILE" "$RELEASE_NAME"
58+
echo "Created source archive $RELEASE_FILE with content: $(ls -a "$RELEASE_NAME")"
59+
- name: Upload source distribution for release
60+
if: ${{ github.event_name == 'release' }}
61+
uses: softprops/action-gh-release@v2
62+
with:
63+
files: ${{env.RELEASE_FILE}}
64+
- name: Upload source distribution to GHA artifacts for release tags
65+
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'rc') }}
66+
uses: actions/[email protected]
67+
with:
68+
name: ${{ env.RELEASE_FILE }}
69+
path: ${{ env.RELEASE_FILE }}
70+
- name: Set output
71+
id: release_name
72+
run: echo "name=release_name::${{ env.RELEASE_NAME }}.tar.gz" >> "${GITHUB_OUTPUT}"
73+
74+
concurrency:
75+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name }}
76+
cancel-in-progress: true

0 commit comments

Comments
 (0)