mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2024-11-25 23:06:09 +03:00
b661d94278
https://github.com/gradle/actions/releases/tag/v4.0.0 https://github.com/gradle/actions/blob/main/setup-gradle/README.md
121 lines
3.9 KiB
YAML
121 lines
3.9 KiB
YAML
name: Build Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
release-tag:
|
|
description: 'Release Tag (v2.x.x)'
|
|
required: true
|
|
|
|
jobs:
|
|
BuildRelease:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Checkout submodules
|
|
run: git submodule update --init --recursive --remote
|
|
|
|
- name: Setup Java
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: 'zulu'
|
|
java-version: 17
|
|
|
|
- name: Setup Gradle
|
|
uses: gradle/actions/setup-gradle@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.23"
|
|
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cache/go-build
|
|
~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
|
|
- name: Convert and set version env
|
|
id: process-version
|
|
run: |
|
|
VERSION_TAG=${{ inputs.release-tag }}
|
|
VERSION_TAG=${VERSION_TAG#v} # remove the 'v' prefix
|
|
IFS='.' read -ra VERSION_PARTS <<< "$VERSION_TAG" # split into array
|
|
VERSION_CODE=$(printf "%1d%02d%03d" "${VERSION_PARTS[0]}" "${VERSION_PARTS[1]}" "${VERSION_PARTS[2]}")
|
|
|
|
echo "versonName=$VERSION_TAG" >> $GITHUB_OUTPUT # "1.2.3"
|
|
echo "versonCode=$VERSION_CODE" >> $GITHUB_OUTPUT # "102003"
|
|
|
|
# Re-write version in build.gradle.kts
|
|
- name: Re-write version
|
|
uses: Devofure/advance-android-version-actions@v1.5
|
|
with:
|
|
gradlePath: build.gradle.kts
|
|
versionCode: ${{ steps.process-version.outputs.versonCode }}
|
|
versionName: ${{ steps.process-version.outputs.versonName }}
|
|
|
|
# If any change found, commit it and push
|
|
- name: Commit and push if changes
|
|
run: |
|
|
changes=$(git diff --name-only origin/main | wc -l)
|
|
if [ $changes -gt 0 ]
|
|
then
|
|
newVersionName=${{ steps.process-version.outputs.versonName }}
|
|
newVersionCode=${{ steps.process-version.outputs.versonCode }}
|
|
git config --global user.name 'GitHub Action'
|
|
git config --global user.email 'action@github.com'
|
|
git add build.gradle.kts
|
|
git commit -am "Bump version to $newVersionName ($newVersionCode)"
|
|
git tag "v$newVersionName"
|
|
git push --follow-tags
|
|
fi
|
|
|
|
- name: Signing properties
|
|
env:
|
|
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
|
|
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
|
|
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
|
|
run: |
|
|
touch signing.properties
|
|
echo keystore.password="$SIGNING_STORE_PASSWORD" > signing.properties
|
|
echo key.alias="$SIGNING_KEY_ALIAS" >> signing.properties
|
|
echo key.password="$SIGNING_KEY_PASSWORD" >> signing.properties
|
|
|
|
echo "cat signing.properties"
|
|
cat signing.properties
|
|
|
|
- name: Release Build
|
|
if: success()
|
|
run: ./gradlew --no-daemon app:assembleMetaRelease
|
|
|
|
- name: Tag Repo
|
|
uses: richardsimko/update-tag@v1
|
|
with:
|
|
tag_name: ${{ inputs.release-tag }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Upload Release
|
|
uses: softprops/action-gh-release@v1
|
|
if: ${{ success() }}
|
|
with:
|
|
tag_name: ${{ inputs.release-tag }}
|
|
files: app/build/outputs/apk/meta/release/*
|
|
generate_release_notes: true
|
|
|
|
- name: Release Changelog Builder
|
|
uses: mikepenz/release-changelog-builder-action@v4.1.1
|
|
with:
|
|
configurationJson: |
|
|
{
|
|
"ignore_labels": [
|
|
"Update"
|
|
],
|
|
} |