11name : CI
22
33on :
4- workflow_dispatch : # allows manual triggering
5- inputs :
6- create_release :
7- description : ' Create new release'
8- required : true
9- type : boolean
104 push :
115 branches :
12- - master
6+ - main
7+ tags : ['v*.*.*']
138 paths : ['.github/workflows/**', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu']
149 pull_request :
1510 types : [opened, synchronize, reopened]
1914 BRANCH_NAME : ${{ github.head_ref || github.ref_name }}
2015
2116jobs :
17+ create-draft-release :
18+ runs-on : ubuntu-latest
19+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
20+ outputs :
21+ upload_url : ${{ steps.create_release.outputs.upload_url }}
22+ version : ${{ steps.get_version.outputs.version }}
23+ permissions :
24+ contents : write
25+ steps :
26+ - name : Extract tag name without v prefix
27+ id : get_version
28+ run : echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV && echo "::set-output name=version::${GITHUB_REF#refs/tags/v}"
29+ env :
30+ GITHUB_REF : ${{ github.ref }}
31+ - name : Create Draft Release
32+ id : create_release
33+ uses : actions/create-release@v1
34+ env :
35+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
36+ with :
37+ tag_name : ${{ github.ref_name }}
38+ release_name : ${{ env.VERSION }}
39+ draft : true
40+ prerelease : false
41+
2242 ubuntu-amd64-build :
2343 runs-on : ubuntu-20.04
44+ needs : create-draft-release
45+ if : always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped')
2446 permissions :
2547 contents : write
2648 steps :
4567 CC=gcc-8 make -j $(nproc)
4668 ls -la
4769
48- - name : Extract branch name
49- shell : bash
50- id : extract_branch
51- run : echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
52- - name : Extract commit short SHA
53- id : extract_commit_id
54- run : echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
55-
5670 - name : Package
5771 shell : bash
5872 run : |
@@ -61,17 +75,20 @@ jobs:
6175 cp build/nitro nitro/
6276 zip -r nitro.zip nitro
6377
64- - name : Upload binaries to release
65- if : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
66- uses : svenstaro/upload-release-action@v2
78+ - uses : actions/upload-release-asset@v1.0.1
79+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
80+ env :
81+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6782 with :
68- repo_token : ${{ secrets.GITHUB_TOKEN }}
69- file : nitro.zip
70- asset_name : nitro-${{ steps.extract_commit_id .outputs.sha_short }}-linux-amd64.zip
71- tag : ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }}
83+ upload_url : ${{ needs.create-draft-release.outputs.upload_url }}
84+ asset_path : ./ nitro.zip
85+ asset_name : nitro-${{ needs.create-draft-release .outputs.version }}-linux-amd64.zip
86+ asset_content_type : application/zip
7287
7388 ubuntu-amd64-cuda-build :
7489 runs-on : linux-gpu
90+ needs : create-draft-release
91+ if : always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped')
7592 permissions :
7693 contents : write
7794 steps :
@@ -94,16 +111,7 @@ jobs:
94111 mkdir build && cd build
95112 cmake -DLLAMA_CUBLAS=ON ..
96113 CC=gcc-8 make -j $(nproc)
97- ls -la
98-
99- - name : Extract branch name
100- shell : bash
101- id : extract_branch
102- run : echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
103-
104- - name : Extract commit short SHA
105- id : extract_commit_id
106- run : echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
114+ ls -la
107115
108116 - name : Package
109117 shell : bash
@@ -113,17 +121,20 @@ jobs:
113121 cp build/nitro nitro/
114122 zip -r nitro.zip nitro
115123
116- - name : Upload binaries to release
117- if : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
118- uses : svenstaro/upload-release-action@v2
124+ - uses : actions/upload-release-asset@v1.0.1
125+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
126+ env :
127+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
119128 with :
120- repo_token : ${{ secrets.GITHUB_TOKEN }}
121- file : nitro.zip
122- asset_name : nitro-${{ steps.extract_commit_id .outputs.sha_short }}-linux-amd64-cuda.zip
123- tag : ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }}
129+ upload_url : ${{ needs.create-draft-release.outputs.upload_url }}
130+ asset_path : ./ nitro.zip
131+ asset_name : nitro-${{ needs.create-draft-release .outputs.version }}-linux-amd64-cuda.zip
132+ asset_content_type : application/zip
124133
125134 macOS-M-build :
126135 runs-on : mac-silicon
136+ needs : create-draft-release
137+ if : always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped')
127138 permissions :
128139 contents : write
129140 steps :
@@ -147,16 +158,7 @@ jobs:
147158 mkdir build && cd build
148159 cmake ..
149160 CC=gcc-8 make -j $(nproc)
150- ls -la
151-
152- - name : Extract branch name
153- shell : bash
154- id : extract_branch
155- run : echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
156-
157- - name : Extract commit short SHA
158- id : extract_commit_id
159- run : echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
161+ ls -la
160162
161163 - name : Package
162164 shell : bash
@@ -167,17 +169,20 @@ jobs:
167169 cp build/nitro nitro/
168170 zip -r nitro.zip nitro
169171
170- - name : Upload binaries to release
171- if : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
172- uses : svenstaro/upload-release-action@v2
172+ - uses : actions/upload-release-asset@v1.0.1
173+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
174+ env :
175+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
173176 with :
174- repo_token : ${{ secrets.GITHUB_TOKEN }}
175- file : nitro.zip
176- asset_name : nitro-${{ steps.extract_commit_id .outputs.sha_short }}-mac-arm64.zip
177- tag : ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }}
177+ upload_url : ${{ needs.create-draft-release.outputs.upload_url }}
178+ asset_path : ./ nitro.zip
179+ asset_name : nitro-${{ needs.create-draft-release .outputs.version }}-mac-arm64.zip
180+ asset_content_type : application/zip
178181
179182 macOS-Intel-build :
180183 runs-on : macos-latest
184+ needs : create-draft-release
185+ if : always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped')
181186 permissions :
182187 contents : write
183188 steps :
@@ -200,16 +205,7 @@ jobs:
200205 mkdir build && cd build
201206 cmake -DLLAMA_METAL=OFF ..
202207 CC=gcc-8 make -j $(nproc)
203- ls -la
204-
205- - name : Extract branch name
206- shell : bash
207- id : extract_branch
208- run : echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
209-
210- - name : Extract commit short SHA
211- id : extract_commit_id
212- run : echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
208+ ls -la
213209
214210 - name : Package
215211 shell : bash
@@ -219,11 +215,36 @@ jobs:
219215 cp build/nitro nitro/
220216 zip -r nitro.zip nitro
221217
222- - name : Upload binaries to release
223- if : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
224- uses : svenstaro/upload-release-action@v2
218+ - uses : actions/upload-release-asset@v1.0.1
219+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
220+ env :
221+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
225222 with :
226- repo_token : ${{ secrets.GITHUB_TOKEN }}
227- file : nitro.zip
228- asset_name : nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-amd64.zip.zip
229- tag : ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }}
223+ upload_url : ${{ needs.create-draft-release.outputs.upload_url }}
224+ asset_path : ./nitro.zip
225+ asset_name : nitro-${{ needs.create-draft-release.outputs.version }}-mac-amd64.zip
226+ asset_content_type : application/zip
227+
228+ update_release_draft :
229+ needs : [ubuntu-amd64-build, ubuntu-amd64-cuda-build, macOS-M-build, macOS-Intel-build]
230+ permissions :
231+ # write permission is required to create a github release
232+ contents : write
233+ # write permission is required for autolabeler
234+ # otherwise, read permission is required at least
235+ pull-requests : write
236+ runs-on : ubuntu-latest
237+ steps :
238+ # (Optional) GitHub Enterprise requires GHE_HOST variable set
239+ # - name: Set GHE_HOST
240+ # run: |
241+ # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
242+
243+ # Drafts your next Release notes as Pull Requests are merged into "master"
244+ - uses : release-drafter/release-drafter@v5
245+ # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
246+ # with:
247+ # config-name: my-config.yml
248+ # disable-autolabeler: true
249+ env :
250+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments