Skip to content

Commit 0d21b63

Browse files
nichu42Copilot
andcommitted
fix(release): handle manual workflow runs gracefully
The release job failed when triggered manually because action-gh-release requires a tag. Extract versionName from build.gradle.kts, upload the APK as a workflow artifact on workflow_dispatch, and only publish to GitHub Releases on tag pushes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 393ed8a commit 0d21b63

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,26 @@ jobs:
3939
chmod +x ./gradlew
4040
./gradlew assembleRelease --no-daemon -Dorg.gradle.jvmargs="-Xmx2048m" -Dorg.gradle.workers.max=2 --warning-mode all
4141
42+
- name: Extract version name
43+
id: version
44+
run: |
45+
version=$(sed -n 's/.*versionName = "\([^"]*\)".*/\1/p' app/build.gradle.kts)
46+
echo "version=$version" >> "$GITHUB_OUTPUT"
47+
4248
- name: Rename release APK
43-
run: cp app/build/outputs/apk/release/app-release.apk "BoxViewer-${{ github.ref_name }}.apk"
49+
run: cp app/build/outputs/apk/release/app-release.apk "BoxViewer-${{ steps.version.outputs.version }}.apk"
50+
51+
- name: Upload APK artifact for manual runs
52+
if: github.event_name == 'workflow_dispatch'
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: BoxViewer-${{ steps.version.outputs.version }}
56+
path: BoxViewer-${{ steps.version.outputs.version }}.apk
4457

4558
- name: Upload release APK to GitHub Releases
59+
if: startsWith(github.ref, 'refs/tags/v')
4660
uses: softprops/action-gh-release@v2
4761
with:
4862
name: ${{ github.ref_name }}
49-
files: BoxViewer-${{ github.ref_name }}.apk
63+
files: BoxViewer-${{ steps.version.outputs.version }}.apk
5064
generate_release_notes: true

0 commit comments

Comments
 (0)