-
Notifications
You must be signed in to change notification settings - Fork 61
57 lines (55 loc) · 1.46 KB
/
release.yml
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
55
56
57
name: Release
on:
push:
branches:
- main
paths:
- '*.yaml' # root directory only
- '*.txt'
- 'opencc/**'
schedule:
- cron: '45 8 * * 4' # run every week
workflow_dispatch:
jobs:
package:
uses: ./.github/workflows/package.yml
with:
event_name: ${{ github.event_name }}
secrets: inherit
release:
needs: package
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Latest Commit
uses: actions/checkout@v4
with:
filter: blob:none
- name: Tag the Latest Commit
run: |
git tag -f latest
git push -f origin latest
- name: Download Artifact
uses: actions/download-artifact@v4
with:
path: output
pattern: package-*
merge-multiple: true
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: |
if [ ! -d output ]; then
echo "No artifacts to release."
exit 0
fi
assets=$(gh release view latest --json assets --jq '.assets[].name')
for prefix in $(ls output | xargs -n 1 basename | sed 's/-.*/-/' | sort -u); do
for asset in $(echo "$assets" | grep "^$prefix"); do
gh release delete-asset latest "$asset" -y
done
done
for file in output/*; do
gh release upload latest "$file"
done