-
Notifications
You must be signed in to change notification settings - Fork 34
80 lines (69 loc) · 2.8 KB
/
Copy pathupdate-versions.yml
File metadata and controls
80 lines (69 loc) · 2.8 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
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
name: Update versions
on:
schedule:
# Every hour at :00
- cron: "0 * * * *"
workflow_dispatch:
permissions:
contents: write
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
token: ${{ secrets.PAT_TOKEN }}
- name: Fetch latest versions from GitHub
id: fetch
run: |
KITSU_VERSION=$(curl -s https://api.github.com/repos/cgwire/kitsu/releases/latest | jq -r '.tag_name' | sed 's/^v//')
ZOU_VERSION=$(curl -s https://api.github.com/repos/cgwire/zou/tags | jq -r '.[0].name' | sed 's/^v//')
for v in "$KITSU_VERSION" "$ZOU_VERSION"; do
if ! echo "$v" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::Invalid version format: $v"
exit 1
fi
done
echo "KITSU_VERSION=${KITSU_VERSION}" >> "$GITHUB_OUTPUT"
echo "ZOU_VERSION=${ZOU_VERSION}" >> "$GITHUB_OUTPUT"
- name: Compare with current versions
id: compare
env:
LATEST_KITSU: ${{ steps.fetch.outputs.KITSU_VERSION }}
LATEST_ZOU: ${{ steps.fetch.outputs.ZOU_VERSION }}
run: |
set -a
source versions.env
set +a
echo "Current: Kitsu=${KITSU_VERSION} Zou=${ZOU_VERSION}"
echo "Latest: Kitsu=${LATEST_KITSU} Zou=${LATEST_ZOU}"
if [ "$KITSU_VERSION" = "$LATEST_KITSU" ] && [ "$ZOU_VERSION" = "$LATEST_ZOU" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No updates needed."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "Updates available!"
fi
- name: Update versions.env
if: steps.compare.outputs.changed == 'true'
env:
LATEST_KITSU: ${{ steps.fetch.outputs.KITSU_VERSION }}
LATEST_ZOU: ${{ steps.fetch.outputs.ZOU_VERSION }}
run: |
sed -i "s/^KITSU_VERSION=.*/KITSU_VERSION=${LATEST_KITSU}/" versions.env
sed -i "s/^ZOU_VERSION=.*/ZOU_VERSION=${LATEST_ZOU}/" versions.env
sed -i "s/^INDEX_VERSION=.*/INDEX_VERSION=01/" versions.env
cat versions.env
- name: Commit and push
if: steps.compare.outputs.changed == 'true'
env:
LATEST_KITSU: ${{ steps.fetch.outputs.KITSU_VERSION }}
LATEST_ZOU: ${{ steps.fetch.outputs.ZOU_VERSION }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add versions.env
git commit -m "Bump Kitsu and Zou versions (${LATEST_KITSU} and ${LATEST_ZOU})"
git tag "${LATEST_KITSU}-${LATEST_ZOU}-01"
git push origin master --tags