forked from starifly/NekoBoxForAndroid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathandroid-release-to-github-release.yml
More file actions
134 lines (114 loc) · 3.96 KB
/
Copy pathandroid-release-to-github-release.yml
File metadata and controls
134 lines (114 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Android release to GitHub Releases
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
on:
workflow_dispatch:
inputs:
tag:
description: Release tag. Leave empty to auto-generate.
required: false
type: string
title:
description: Release title. Leave empty to auto-generate.
required: false
type: string
release:
types:
- published
permissions:
contents: write
concurrency:
group: android-release-github-release-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '17'
cache: gradle
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26.4'
cache-dependency-path: |
libcore/go.sum
libcore/go.mod
- name: Set up Android SDK
uses: android-actions/setup-android@v4
- name: Install required Android packages
run: |
sdkmanager --install \
"platform-tools" \
"platforms;android-35" \
"build-tools;35.0.1" \
"ndk;25.0.8775105"
- name: Make scripts executable
run: |
chmod +x ./gradlew ./run
chmod +x buildScript/lib/core.sh buildScript/lib/core/init.sh buildScript/lib/core/build.sh
chmod +x buildScript/lib/core/get_source.sh buildScript/init/env.sh buildScript/init/env_ndk.sh
chmod +x libcore/init.sh libcore/build.sh
- name: Resolve release metadata
id: meta
shell: bash
run: |
VERSION_NAME=$(grep '^VERSION_NAME=' nb4a.properties | cut -d= -f2-)
DEFAULT_TAG="v${VERSION_NAME}-${GITHUB_RUN_NUMBER}"
DEFAULT_TITLE="NekoBox_SF ${VERSION_NAME}"
if [ "${{ github.event_name }}" = "release" ]; then
TAG="${{ github.event.release.tag_name }}"
TITLE="${{ github.event.release.name }}"
if [ -z "$TITLE" ]; then
TITLE="$DEFAULT_TITLE"
fi
else
TAG='${{ inputs.tag }}'
TITLE='${{ inputs.title }}'
if [ -z "$TAG" ]; then
TAG="$DEFAULT_TAG"
fi
if [ -z "$TITLE" ]; then
TITLE="$DEFAULT_TITLE"
fi
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "title=$TITLE" >> "$GITHUB_OUTPUT"
- name: Build libcore AAR
run: ./buildScript/lib/core.sh
- name: Verify libcore AAR exists
run: test -f app/libs/libcore.aar
- name: Build installable OSS debug APK
run: ./gradlew --no-daemon :app:assembleOssDebug
- name: Collect release assets
shell: bash
run: |
mkdir -p release-assets
find app/build/outputs/apk/oss/debug -type f -name "*.apk" -print -exec cp -v {} release-assets/ \;
test -n "$(find release-assets -maxdepth 1 -type f -name "*.apk" -print -quit)" || { echo "No OSS debug APK files found"; exit 1; }
(
cd release-assets
sha256sum *.apk > SHA256SUMS.txt
)
- name: Create release when started manually
if: github.event_name == 'workflow_dispatch'
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if ! gh release view "${{ steps.meta.outputs.tag }}" >/dev/null 2>&1; then
gh release create "${{ steps.meta.outputs.tag }}" \
--title "${{ steps.meta.outputs.title }}" \
--notes "Automated Android release build uploaded by GitHub Actions."
fi
- name: Upload APKs to GitHub Release
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "${{ steps.meta.outputs.tag }}" release-assets/* --clobber