Skip to content

Commit ab38c4a

Browse files
authored
Added github workflow to create PR artifacts and release on tag (#35)
1 parent e88b345 commit ab38c4a

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

.github/workflows/ci.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
tags:
8+
- "v*"
9+
workflow_dispatch: # allows manual run too
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
container:
15+
image: fozztexx/defoogi:1.4.2
16+
17+
outputs:
18+
files: ${{ steps.list_zips.outputs.files }}
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Build release files
24+
run: make release
25+
26+
- name: List zip files
27+
id: list_zips
28+
shell: bash
29+
run: |
30+
echo 'files=["'"$(( cd dist ; echo *.zip ) | sed -e 's/ /","/g')"'"]' >> $GITHUB_OUTPUT
31+
32+
- name: Upload dist folder for next job
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: dist
36+
path: dist/
37+
38+
upload:
39+
needs: build
40+
runs-on: ubuntu-latest
41+
if: github.event_name == 'pull_request'
42+
strategy:
43+
matrix:
44+
file: ${{ fromJson(needs.build.outputs.files) }}
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Download dist folder
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: dist
52+
path: dist
53+
54+
- name: Upload individual artifact
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: ${{ matrix.file }}
58+
path: dist/${{ matrix.file }}
59+
60+
tagged-release:
61+
needs: build
62+
runs-on: ubuntu-latest
63+
if: startsWith(github.ref, 'refs/tags/')
64+
steps:
65+
- uses: actions/checkout@v4
66+
67+
# Download the dist folder from the build job
68+
- name: Download build artifacts
69+
uses: actions/download-artifact@v4
70+
with:
71+
name: dist
72+
path: dist
73+
74+
# Create GitHub Release for the tag
75+
- name: Create GitHub Release
76+
id: create_release
77+
uses: actions/create-release@v1
78+
with:
79+
tag_name: ${{ github.ref_name }}
80+
release_name: Release ${{ github.ref_name }}
81+
draft: false
82+
prerelease: false
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
86+
# Upload each zip as a release asset
87+
- name: Upload release assets
88+
run: |
89+
for zip in dist/*.zip; do
90+
echo "Uploading $zip..."
91+
gh release upload ${{ github.ref_name }} "$zip"
92+
done
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)