-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (149 loc) · 5.27 KB
/
build.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Build and release
on:
workflow_dispatch:
push:
schedule:
- cron: "0 */12 * * *"
env:
RELEASE_TAG: packages
jobs:
check:
runs-on: ubuntu-latest
env:
KEYFILE: keyfile.toml
permissions: write-all
outputs:
matrix: ${{ steps.checker.outputs.matrix }}
build_status: ${{ steps.checker.outputs.build_status }}
remove_status: ${{ steps.checker.outputs.remove_status }}
remove_pkgs: ${{ steps.checker.outputs.remove_pkgs }}
steps:
- name: Checkout to repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
run: |
echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
- name: Set keyfile.toml
run: |
if [ ! -f ${{ env.KEYFILE }} ]; then
echo "${{ env.KEYFILE }} not found"
exit 1
fi
sed -i -e "s/__GITHUB_ACCESS_TOKEN__/${{ github.token }}/g" ${{ env.KEYFILE }}
- name: nvchecker and update
id: checker
uses: ./nvcheck-and-update
with:
changed_files: ${{ steps.changed-files.outputs.changed_files }}
keyfile: ${{ env.KEYFILE }}
- uses: stefanzweifel/git-auto-commit-action@v5
if: steps.checker.outputs.build_status == 'true' || steps.checker.outputs.remove_status == 'true'
with:
file_pattern: ${{ steps.checker.outputs.oldver_file }}
commit_message: ⏰ auto updated oldver file
Repo_Remove:
if: needs.check.outputs.remove_status == 'true'
runs-on: ubuntu-latest
permissions: write-all
needs: check
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Remove old packages
uses: ./repo-action
env:
GH_TOKEN: ${{ github.token }}
with:
request: "remove"
remove_pkgs: ${{ needs.check.outputs.remove_pkgs }}
- name: Update repo db
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
files: |
${{ github.workspace }}/*.files
${{ github.workspace }}/*.files.tar.gz
${{ github.workspace }}/*.db
${{ github.workspace }}/*.db.tar.gz
generate_release_notes: true
Build:
if: needs.check.outputs.build_status == 'true'
permissions: write-all
needs: check
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.check.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: ./arch-build
id: build
with:
pkg: ${{ matrix.pkg }}
version: ${{ matrix.version }}
- name: Pull Remote Changes
run: git pull --rebase --autostash
- uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: "${{ matrix.pkg }}/PKGBUILD"
commit_message: ⏰ ${{ matrix.pkg }}:auto updated to ${{ matrix.version }}
- name: Upload Packages Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build.outputs.asset }}
path: ${{ matrix.pkg }}/${{ steps.build.outputs.asset }}
if-no-files-found: error
- name: Delete old asset
env:
GH_TOKEN: ${{ github.token }}
run: |
assets=$(gh release view --json assets | jq -r '.assets[].name')
if [[ "$assets" =~ ${{ matrix.pkg }}-${{ matrix.old_pkgver }}.*pkg.tar.zst ]]; then
pkg_assets=$(echo "$assets" | grep -E "^${{ matrix.pkg }}-${{ matrix.old_pkgver }}.*pkg.tar.zst")
for asset in $pkg_assets; do
echo "Deleting asset: $asset"
gh release delete-asset packages "$asset" -y
done
else
echo "No matching assets found. Exiting with code 0."
exit 0
fi
Release:
needs: [Build, Repo_Remove]
if: ${{ !cancelled() && (needs.Build.result == 'success' || needs.Repo_Remove.result == 'success') }}
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Pull Remote Changes
run: git pull --rebase --autostash
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- uses: ./repo-action
env:
GH_TOKEN: ${{ github.token }}
with:
request: "add"
- name: Upload Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
files: |
${{ github.workspace }}/*.pkg.tar.zst
${{ github.workspace }}/*.files
${{ github.workspace }}/*.db
${{ github.workspace }}/*.db.tar.gz
generate_release_notes: true
- name: Send notify to telegram
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: "From ${{ github.repository }} - ${{ github.workflow }}: \n Packages build success!\n[View it On Github](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})\n"