-
-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (44 loc) · 1.45 KB
/
artifact.yml
File metadata and controls
54 lines (44 loc) · 1.45 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
name: Attach artifact to release
on:
release:
types: [published]
permissions:
contents: write
jobs:
build:
uses: ./.github/workflows/build.yml
attach:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Upload Release Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
release_tag="${{ inputs.release_tag || github.event.release.tag_name }}"
if [ -z "$release_tag" ]; then
echo "Error: No release tag provided"
exit 1
fi
# Get existing release assets
existing_assets=$(gh release view "$release_tag" --json assets --jq '.assets[].name')
# Upload new artifacts
uploaded=false
for file in artifacts/*/*.zip; do
if [ -f "$file" ]; then
filename=$(basename "$file")
if ! echo "$existing_assets" | grep -q "$filename"; then
gh release upload "$release_tag" "$file" --clobber
echo "Uploaded $filename to release $release_tag"
uploaded=true
else
echo "Skipped $filename (already exists in release $release_tag)"
fi
fi
done
$uploaded || echo "No new artifacts were uploaded to the release."