Skip to content

Commit 5703cd4

Browse files
committed
version update CI
1 parent dbc3e34 commit 5703cd4

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Auto-update fpm Formula
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *" # Runs daily at midnight UTC
6+
workflow_dispatch: # Allows manual trigger
7+
8+
jobs:
9+
update-fpm:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Fetch latest fpm release
17+
id: get-latest-release
18+
run: |
19+
LATEST_VERSION=$(curl -s https://api.github.com/repos/fortran-lang/fpm/releases/latest | jq -r '.tag_name')
20+
echo "Latest version: $LATEST_VERSION"
21+
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
22+
23+
- name: Extract current formula version
24+
id: get-current-version
25+
run: |
26+
CURRENT_VERSION=$(grep -oP 'url "https://github.com/fortran-lang/fpm/releases/download/v\K[0-9.]+(?=/fpm-)' Formula/fpm.rb)
27+
echo "Current version: $CURRENT_VERSION"
28+
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
29+
30+
- name: Compare versions
31+
id: check-update
32+
run: |
33+
if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; then
34+
echo "New version available!"
35+
echo "UPDATE_NEEDED=true" >> $GITHUB_ENV
36+
else
37+
echo "No update needed."
38+
fi
39+
40+
- name: Get new SHA256 hash
41+
if: env.UPDATE_NEEDED == 'true'
42+
id: get-sha256
43+
run: |
44+
SHA_URL="https://github.com/fortran-lang/fpm/releases/download/${LATEST_VERSION}/fpm-${LATEST_VERSION}.zip.sha256"
45+
SHA256=$(curl -sL $SHA_URL | awk '{print $1}')
46+
echo "New SHA256: $SHA256"
47+
echo "SHA256=$SHA256" >> $GITHUB_ENV
48+
49+
- name: Update formula
50+
if: env.UPDATE_NEEDED == 'true'
51+
run: |
52+
sed -i "s|url \".*\"|url \"https://github.com/fortran-lang/fpm/releases/download/${LATEST_VERSION}/fpm-${LATEST_VERSION}.zip\"|" Formula/fpm.rb
53+
sed -i "s|sha256 \".*\"|sha256 \"${SHA256}\"|" Formula/fpm.rb
54+
55+
- name: Commit and push changes
56+
if: env.UPDATE_NEEDED == 'true'
57+
run: |
58+
git config --global user.name "GitHub Actions"
59+
git config --global user.email "[email protected]"
60+
git add Formula/fpm.rb
61+
git commit -m "Update fpm to ${LATEST_VERSION}"
62+
git push
63+

0 commit comments

Comments
 (0)