Added either automated release build process via tags or plain artifact upload via branch
This commit is contained in:
1 parent
66ec01f042
commit
587eb073a5
1 file changed
+57
-5
@@ -1,8 +1,14 @@
|
|||||||
name: Build Android
|
name: Build Android
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags: ['v*']
|
tags: ['v*']
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Existing tag to build and publish to its release (leave empty for a plain branch build)'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -13,10 +19,20 @@ jobs:
|
|||||||
ANDROID_HOME: ${{ vars.ANDROID_HOME }}
|
ANDROID_HOME: ${{ vars.ANDROID_HOME }}
|
||||||
PATH: ${{ vars.NODE_BIN_DIR }}:${{ vars.JAVA_HOME }}/bin:${{ vars.ANDROID_HOME }}/cmdline-tools/latest/bin:${{ vars.ANDROID_HOME }}/platform-tools:/usr/local/bin:/usr/bin:/bin
|
PATH: ${{ vars.NODE_BIN_DIR }}:${{ vars.JAVA_HOME }}/bin:${{ vars.ANDROID_HOME }}/cmdline-tools/latest/bin:${{ vars.ANDROID_HOME }}/platform-tools:/usr/local/bin:/usr/bin:/bin
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Decide what we're building
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
TAG=""
|
||||||
|
if [ -n "${{ inputs.tag }}" ]; then
|
||||||
|
TAG="${{ inputs.tag }}"
|
||||||
|
elif [ "${{ gitea.ref_type }}" = "tag" ]; then
|
||||||
|
TAG="${{ gitea.ref_name }}"
|
||||||
|
fi
|
||||||
|
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Verify toolchain
|
- uses: actions/checkout@v4
|
||||||
run: node -v && npm -v && java -version && javac -version && sdkmanager --version
|
with:
|
||||||
|
ref: ${{ inputs.tag }} # empty = the triggering ref (tag push or selected branch)
|
||||||
|
|
||||||
- name: Add google-services.json
|
- name: Add google-services.json
|
||||||
run: |
|
run: |
|
||||||
@@ -26,12 +42,48 @@ jobs:
|
|||||||
git add -A
|
git add -A
|
||||||
git -c user.name=ci -c user.email=ci@local commit -m "ci: add google-services.json"
|
git -c user.name=ci -c user.email=ci@local commit -m "ci: add google-services.json"
|
||||||
|
|
||||||
|
- name: Verify toolchain
|
||||||
|
run: node -v && npm -v && java -version && javac -version && sdkmanager --version
|
||||||
|
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: npx eas-cli build --profile release --local --platform android --non-interactive --output "$PWD/notifier.apk"
|
run: npx eas-cli build --profile release --local --platform android --non-interactive --output "$PWD/notifier.apk"
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
# Manual branch build
|
||||||
|
- name: Upload artifact
|
||||||
|
if: steps.meta.outputs.tag == ''
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: notifier-apk
|
name: notifier-${{ gitea.ref_name }}-${{ gitea.sha }}
|
||||||
path: notifier.apk
|
path: notifier.apk
|
||||||
|
|
||||||
|
# Tag build
|
||||||
|
- name: Publish release
|
||||||
|
if: steps.meta.outputs.tag != ''
|
||||||
|
env:
|
||||||
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
TAG: ${{ steps.meta.outputs.tag }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
API="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}"
|
||||||
|
AUTH="Authorization: token $RELEASE_TOKEN"
|
||||||
|
NAME="notifier-$TAG.apk"
|
||||||
|
|
||||||
|
RELEASE_ID=$(curl -s -H "$AUTH" "$API/releases/tags/$TAG" | jq -r '.id // empty')
|
||||||
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
|
RELEASE_ID=$(curl -fsS -X POST "$API/releases" -H "$AUTH" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"Automated build of $TAG\"}" \
|
||||||
|
| jq -r .id)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# on a re-run, replace the asset of the same name instead of failing
|
||||||
|
OLD_ID=$(curl -s -H "$AUTH" "$API/releases/$RELEASE_ID/assets" \
|
||||||
|
| jq -r --arg n "$NAME" '.[] | select(.name==$n) | .id')
|
||||||
|
if [ -n "$OLD_ID" ]; then
|
||||||
|
curl -fsS -X DELETE -H "$AUTH" "$API/releases/$RELEASE_ID/assets/$OLD_ID"
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -fsS -X POST "$API/releases/$RELEASE_ID/assets?name=$NAME" \
|
||||||
|
-H "$AUTH" -F "attachment=@notifier.apk"
|
||||||
Reference in new issue
Block a user