Skip to content

Commit c08a602

Browse files
committed
Fix the flaky Edge release step by force-moving its tag instead of deleting the release, and update the CI actions to current majors
1 parent 80a5783 commit c08a602

1 file changed

Lines changed: 69 additions & 72 deletions

File tree

‎.github/workflows/android.yml‎

Lines changed: 69 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,33 @@ on:
88
jobs:
99
apk:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
1113
steps:
1214
- name: Checkout repository and submodules
13-
uses: actions/checkout@v3
15+
uses: actions/checkout@v7
1416
with:
1517
submodules: recursive
1618
fetch-depth: 0 # Needed for version generation
17-
19+
1820
- name: set up JDK 17
19-
uses: actions/setup-java@v3
21+
uses: actions/setup-java@v5
2022
with:
2123
java-version: '17'
2224
distribution: 'temurin'
2325
cache: gradle
24-
26+
2527
- name: Setup Android SDK
26-
uses: android-actions/setup-android@v3
27-
28+
uses: android-actions/setup-android@v4
29+
2830
- name: Install Ninja and check Android SDK
2931
run: |
3032
sudo apt-get update
3133
sudo apt-get install -y ninja-build
32-
34+
3335
- name: Set permissions for gradlew
3436
run: chmod +x gradlew
35-
37+
3638
- name: Check Android SDK Details
3739
run: |
3840
echo "SDK Location:"
@@ -43,7 +45,7 @@ jobs:
4345
ls -la $ANDROID_SDK_ROOT/platform-tools/
4446
echo "NDK versions:"
4547
ls -la $ANDROID_SDK_ROOT/ndk/
46-
48+
4749
# Generate version based on date and commit
4850
- name: Generate version
4951
id: version
@@ -53,11 +55,11 @@ jobs:
5355
VERSION="${DATE}-${SHORT_SHA}"
5456
echo "version=${VERSION}" >> $GITHUB_OUTPUT
5557
echo "Generated version: ${VERSION}"
56-
58+
5759
- name: Build
5860
run: ./gradlew build
59-
60-
- uses: ilharp/sign-android-release@v1
61+
62+
- uses: ilharp/sign-android-release@v2
6163
name: Sign app APK
6264
id: sign_app
6365
with:
@@ -68,85 +70,80 @@ jobs:
6870
keyPassword: ${{ secrets.KEY_PASSWORD }}
6971
buildToolsVersion: 34.0.0
7072

73+
# Collect both APKs under stable names, used by the releases and the artifacts
74+
- name: Stage release assets
75+
run: |
76+
mkdir -p dist
77+
cp app/build/outputs/apk/debug/app-debug.apk dist/app-debug.apk
78+
cp "${{ steps.sign_app.outputs.signedFile }}" dist/app-release-signed.apk
79+
ls -la dist
80+
7181
# Only create releases on pushes to master, not on PRs
7282
- name: Create Release
7383
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
74-
id: create_release
75-
uses: actions/create-release@v1
76-
env:
77-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78-
with:
79-
tag_name: v${{ steps.version.outputs.version }}
80-
release_name: AIS Catcher v${{ steps.version.outputs.version }}
81-
body: |
82-
Automated release of AIS Catcher
83-
84-
Built from commit: ${{ github.sha }}
85-
86-
## Changes
87-
- Latest updates from master branch
88-
89-
## Downloads
90-
- **app-debug.apk**: Debug version for testing
91-
- **app-release-signed.apk**: Production-ready signed APK
92-
draft: false
93-
prerelease: false
94-
95-
- name: Upload Debug APK to Release
96-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
97-
uses: actions/upload-release-asset@v1
98-
env:
99-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100-
with:
101-
upload_url: ${{ steps.create_release.outputs.upload_url }}
102-
asset_path: app/build/outputs/apk/debug/app-debug.apk
103-
asset_name: app-debug.apk
104-
asset_content_type: application/vnd.android.package-archive
105-
106-
- name: Upload Signed APK to Release
107-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
108-
uses: actions/upload-release-asset@v1
10984
env:
11085
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111-
with:
112-
upload_url: ${{ steps.create_release.outputs.upload_url }}
113-
asset_path: ${{ steps.sign_app.outputs.signedFile }}
114-
asset_name: app-release-signed.apk
115-
asset_content_type: application/vnd.android.package-archive
86+
run: |
87+
gh release create "v${{ steps.version.outputs.version }}" \
88+
--title "AIS Catcher v${{ steps.version.outputs.version }}" \
89+
--target "$GITHUB_SHA" \
90+
--notes "Automated release of AIS Catcher
91+
92+
Built from commit: ${{ github.sha }}
93+
94+
## Downloads
95+
- **app-debug.apk**: Debug version for testing
96+
- **app-release-signed.apk**: Production-ready signed APK" \
97+
dist/app-debug.apk \
98+
dist/app-release-signed.apk
11699
117-
# Update Edge release for backward compatibility
100+
# Edge keeps one long-lived release so the download URLs never change.
101+
# The tag is force-moved rather than the release deleted and recreated:
102+
# recreating hands out a fresh release id whose upload endpoint 404s until
103+
# GitHub catches up, and a plain delete leaves the old tag behind.
118104
- name: Update Edge release
119105
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
120106
env:
121107
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122108
run: |
123-
# Delete existing Edge release if it exists
124-
gh release delete Edge --yes || true
125-
# Create new Edge release
126-
gh release create Edge \
127-
--title "Latest Edge Build" \
128-
--notes "Always contains the latest build from master branch.
129-
109+
NOTES="Always contains the latest build from master branch.
110+
130111
**Note:** This release is updated automatically and maintains the same download URLs for backward compatibility.
131-
112+
132113
For version-specific releases and automated updates, please use the numbered releases above.
133-
114+
134115
Built from commit: ${{ github.sha }}
135-
Version: v${{ steps.version.outputs.version }}" \
136-
--prerelease
137-
# Upload APKs to Edge release
138-
gh release upload Edge app/build/outputs/apk/debug/app-debug.apk --clobber
139-
gh release upload Edge ${{ steps.sign_app.outputs.signedFile }} --clobber
116+
Version: v${{ steps.version.outputs.version }}"
117+
118+
git tag -f Edge "$GITHUB_SHA"
119+
git push -f origin refs/tags/Edge
120+
121+
if gh release view Edge >/dev/null 2>&1; then
122+
gh release edit Edge --title "Latest Edge Build" --notes "$NOTES" --prerelease
123+
else
124+
gh release create Edge --title "Latest Edge Build" --notes "$NOTES" --target "$GITHUB_SHA" --prerelease
125+
fi
126+
127+
n=0
128+
until gh release upload Edge dist/app-debug.apk dist/app-release-signed.apk --clobber; do
129+
n=$((n + 1))
130+
if [ "$n" -ge 5 ]; then
131+
echo "Edge asset upload failed after $n attempts"
132+
exit 1
133+
fi
134+
echo "Edge asset upload failed, retry $n in 10s"
135+
sleep 10
136+
done
140137
141138
# Keep artifacts for PRs and additional backup
142139
- name: Upload Debug APK Artifact
143-
uses: actions/upload-artifact@v4
140+
uses: actions/upload-artifact@v7
144141
with:
145142
name: debug-apk-${{ steps.version.outputs.version }}
146-
path: app/build/outputs/apk/debug/app-debug.apk
147-
143+
path: dist/app-debug.apk
144+
148145
- name: Upload Release APK Artifact
149-
uses: actions/upload-artifact@v4
146+
uses: actions/upload-artifact@v7
150147
with:
151148
name: release-apk-${{ steps.version.outputs.version }}
152-
path: ${{ steps.sign_app.outputs.signedFile }}
149+
path: dist/app-release-signed.apk

0 commit comments

Comments
 (0)