Skip to content

Commit f9d1b5b

Browse files
ci (refactor): split actions
1 parent 19c19d8 commit f9d1b5b

File tree

2 files changed

+42
-51
lines changed

2 files changed

+42
-51
lines changed

.github/workflows/artifact.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Attach artifact to release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
attach-artifact:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Download build artifacts
17+
uses: actions/download-artifact@v4
18+
with:
19+
path: artifacts
20+
21+
- name: Upload Release Assets
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
run: |
25+
release_tag="${{ github.event.release.tag_name }}"
26+
27+
# Get existing release assets
28+
existing_assets=$(gh release view "$release_tag" --json assets --jq '.assets[].name')
29+
30+
# Upload new artifacts
31+
for file in artifacts/*/*.zip; do
32+
if [ -f "$file" ]; then
33+
filename=$(basename "$file")
34+
if ! echo "$existing_assets" | grep -q "$filename"; then
35+
gh release upload "$release_tag" "$file" --clobber
36+
echo "Uploaded $filename to release $release_tag"
37+
else
38+
echo "Skipped $filename (already exists in release $release_tag)"
39+
fi
40+
fi
41+
done
Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
name: Release Please
22

3-
# TODO: revert branches and paths
43
on:
54
push:
6-
# branches: ['main', 'master']
7-
# paths:
8-
# - 'get_cert.py'
9-
# - 'get_cert.spec'
10-
# - 'requirements.txt'
11-
# - '*.md'
5+
branches: ['main', 'master']
126
pull_request:
137
branches: ['main', 'master']
14-
paths:
15-
- 'get_cert.py'
16-
- 'get_cert.spec'
17-
- 'requirements.txt'
18-
- '*.md'
198

209
permissions:
2110
contents: write
@@ -32,42 +21,3 @@ jobs:
3221
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
3322
config-file: release-please-config.json
3423
manifest-file: .release-please-manifest.json
35-
36-
- uses: actions/checkout@v4
37-
if: ${{ steps.release.outputs.releases_created }}
38-
39-
- name: Download and upload artifacts
40-
if: ${{ steps.release.outputs.releases_created }}
41-
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
run: |
44-
if [ -z "${{ steps.release.outputs.tag_name }}" ]; then
45-
echo "No tag name provided. Skipping artifact upload."
46-
exit 0
47-
fi
48-
49-
# Get the latest successful build artifacts
50-
run_id=$(gh run list --workflow=build.yml --branch main --status completed --limit 1 --json databaseId --jq '.[0].databaseId')
51-
if [ -z "$run_id" ]; then
52-
echo "No successful build found. Skipping artifact upload."
53-
exit 0
54-
fi
55-
gh run download $run_id
56-
57-
# Get existing release assets
58-
existing_assets=$(gh release view "${{ steps.release.outputs.tag_name }}" --json assets --jq '.assets[].name' || echo "")
59-
60-
# Upload new artifacts
61-
uploaded=false
62-
for file in */*.zip; do
63-
if [ -f "$file" ]; then
64-
filename=$(basename "$file")
65-
if ! echo "$existing_assets" | grep -q "$filename"; then
66-
gh release upload "${{ steps.release.outputs.tag_name }}" "$file" --clobber
67-
echo "Uploaded $filename to release"
68-
uploaded=true
69-
fi
70-
fi
71-
done
72-
73-
$uploaded || echo "No new artifacts were uploaded to the release."

0 commit comments

Comments
 (0)