Skip to content

Commit 239e9e1

Browse files
authored
Merge branch 'main' into manually_trigger_tests
2 parents 66d1b23 + 3c25114 commit 239e9e1

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

.github/workflows/fpm-version-update.yml

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ jobs:
3535
- name: Compare versions
3636
id: check-update
3737
run: |
38-
if [ "${LATEST_VERSION}" != "${CURRENT_VERSION}" ] || [ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]; then
39-
echo "New version available!"
38+
if [ "${{ env.LATEST_VERSION }}" != "${{ env.CURRENT_VERSION }}" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
39+
echo "New version available or manually triggered!"
4040
echo "UPDATE_NEEDED=true" >> "$GITHUB_ENV"
4141
else
4242
echo "UPDATE_NEEDED=false" >> "$GITHUB_ENV"
@@ -47,52 +47,46 @@ jobs:
4747
if: env.UPDATE_NEEDED == 'true'
4848
id: get-sha256
4949
run: |
50-
SHA_URL="https://github.com/fortran-lang/fpm/releases/download/${LATEST_VERSION_V}/fpm-${LATEST_VERSION}.zip.sha256"
50+
SHA_URL="https://github.com/fortran-lang/fpm/releases/download/${{ env.LATEST_VERSION_V }}/fpm-${{ env.LATEST_VERSION }}.zip.sha256"
5151
SHA256="$(curl -sL "${SHA_URL}" | awk '{print $1}')"
5252
echo "SHA256=${SHA256}" >> "$GITHUB_ENV"
5353
echo "New SHA256: ${SHA256}"
5454
5555
- name: Create branch for update
5656
if: env.UPDATE_NEEDED == 'true'
5757
run: |
58-
BRANCH_NAME="auto-update-fpm-${LATEST_VERSION}"
59-
git checkout -b "${BRANCH_NAME}"
58+
BRANCH_NAME="auto-update-fpm-${{ env.LATEST_VERSION }}-$(date +%s)" # Add timestamp to branch name for uniqueness
6059
echo "BRANCH_NAME=${BRANCH_NAME}" >> "$GITHUB_ENV"
6160
6261
- name: Update formula
6362
if: env.UPDATE_NEEDED == 'true'
6463
run: |
65-
sed -i "1i # Formula last updated on $(date)" Formula/fpm.rb
66-
sed -i "s|url \".*\"|url \"https://github.com/fortran-lang/fpm/releases/download/${LATEST_VERSION_V}/fpm-${LATEST_VERSION}.zip\"|" Formula/fpm.rb
67-
sed -i "s|sha256 \".*\"|sha256 \"${SHA256}\"|" Formula/fpm.rb
68-
69-
- name: Commit changes
70-
if: env.UPDATE_NEEDED == 'true'
71-
run: |
72-
git config --global user.name "GitHub Actions"
73-
git config --global user.email "[email protected]"
74-
git add Formula/fpm.rb
75-
git commit -m "Update fpm to ${LATEST_VERSION}"
76-
77-
- name: Push changes to branch
64+
TIMESTAMP=$(date +%s)
65+
RUN_ID="${{ github.run_id }}-${{ github.run_number }}"
66+
sed -i "1s/^/# Formula last updated on $(date -u +"%Y-%m-%dT%H:%M:%SZ") (Run: ${RUN_ID})\n/" Formula/fpm.rb
67+
sed -i "s|url \".*\"|url \"https://github.com/fortran-lang/fpm/releases/download/${{ env.LATEST_VERSION_V }}/fpm-${{ env.LATEST_VERSION }}.zip\"|" Formula/fpm.rb
68+
sed -i "s|sha256 \".*\"|sha256 \"${{ env.SHA256 }}\"|" Formula/fpm.rb
69+
70+
- name: Debug - Show changes
7871
if: env.UPDATE_NEEDED == 'true'
7972
run: |
80-
git push origin "${BRANCH_NAME}"
73+
git diff Formula/fpm.rb || echo "No changes detected in Formula/fpm.rb"
8174
8275
- name: Create Pull Request
8376
if: env.UPDATE_NEEDED == 'true'
8477
id: create-pr
85-
uses: peter-evans/create-pull-request@v6
78+
uses: peter-evans/create-pull-request@v7
8679
with:
8780
token: ${{ secrets.GITHUB_TOKEN }}
88-
commit-message: "Update fpm to ${{ env.LATEST_VERSION }}"
81+
commit-message: "Update fpm to ${{ env.LATEST_VERSION }} with timestamp"
8982
title: "Update fpm to ${{ env.LATEST_VERSION }}"
9083
body: |
9184
This PR automatically updates the fpm formula to version ${{ env.LATEST_VERSION }}.
9285
9386
**Changes:**
9487
- Updated URL to ${{ env.LATEST_VERSION_V }} release
9588
- Updated SHA256 to match the new release
89+
- Added timestamp to force PR: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
9690
9791
This PR was created automatically by GitHub Actions.
9892
branch: ${{ env.BRANCH_NAME }}
@@ -121,15 +115,13 @@ jobs:
121115
- name: Wait for test-bot to complete
122116
if: env.UPDATE_NEEDED == 'true' && steps.create-pr.outputs.pull-request-number
123117
run: |
124-
# Wait for CI to start and finish (maximum 30 minutes)
125118
echo "Waiting for test-bot workflow to complete..."
126119
PR_NUMBER=${{ steps.create-pr.outputs.pull-request-number }}
127120
timeout=1800 # 30 minutes in seconds
128121
interval=60 # Check every minute
129122
elapsed=0
130123
131124
while [ $elapsed -lt $timeout ]; do
132-
# Check if test-bot workflow has completed
133125
STATUS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
134126
"https://api.github.com/repos/${{ github.repository }}/actions/runs?status=completed&event=pull_request&head_sha=$(git rev-parse HEAD)")
135127
@@ -156,7 +148,6 @@ jobs:
156148
exit 1
157149
fi
158150
159-
# Add label to trigger pr-pull workflow
160151
- name: Add pr-pull label
161152
if: env.UPDATE_NEEDED == 'true' && steps.create-pr.outputs.pull-request-number
162153
uses: actions/github-script@v6

Formula/fpm.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Formula last updated on 2025-03-10
2+
13
class Fpm < Formula
24
desc "Fortran Package Manager (fpm)"
35
homepage "https://fpm.fortran-lang.org"

0 commit comments

Comments
 (0)