Skip to content

Commit 6f58831

Browse files
committed
ci: support alpha/beta prerelease publishing
1 parent 8b624c8 commit 6f58831

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

.github/workflows/android.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ on:
77
- 'v*'
88
pull_request:
99
branches: [ "main" ]
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: 'Release version/tag, e.g. v0.1.0-alpha.1'
14+
required: true
15+
default: 'v0.1.0-alpha.1'
16+
prerelease:
17+
description: 'Mark this release as prerelease'
18+
required: true
19+
type: boolean
20+
default: true
1021

1122
jobs:
1223
build:
@@ -44,13 +55,36 @@ jobs:
4455

4556
release:
4657
needs: build
47-
if: startsWith(github.ref, 'refs/tags/v')
58+
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
4859
runs-on: ubuntu-latest
4960
permissions:
5061
contents: write
5162
steps:
5263
- uses: actions/checkout@v4
5364

65+
- name: Resolve release metadata
66+
id: release_meta
67+
shell: bash
68+
run: |
69+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
70+
TAG_NAME="${{ inputs.version }}"
71+
PRERELEASE="${{ inputs.prerelease }}"
72+
else
73+
TAG_NAME="${GITHUB_REF_NAME}"
74+
if [[ "${TAG_NAME}" == *"-alpha"* ]] || [[ "${TAG_NAME}" == *"-beta"* ]] || [[ "${TAG_NAME}" == *"-rc"* ]]; then
75+
PRERELEASE="true"
76+
else
77+
PRERELEASE="false"
78+
fi
79+
fi
80+
81+
if [[ "${TAG_NAME}" != v* ]]; then
82+
TAG_NAME="v${TAG_NAME}"
83+
fi
84+
85+
echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT"
86+
echo "prerelease=${PRERELEASE}" >> "$GITHUB_OUTPUT"
87+
5488
- name: Download APK
5589
uses: actions/download-artifact@v4
5690
with:
@@ -59,6 +93,9 @@ jobs:
5993
- name: Create Release
6094
uses: ncipollo/release-action@v1
6195
with:
96+
tag: ${{ steps.release_meta.outputs.tag_name }}
97+
name: ${{ steps.release_meta.outputs.tag_name }}
98+
prerelease: ${{ steps.release_meta.outputs.prerelease }}
6299
artifacts: "app-release.apk"
63100
token: ${{ secrets.GITHUB_TOKEN }}
64101
generateReleaseNotes: true

0 commit comments

Comments
 (0)