Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion .github/workflows/build-pre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Checkout submodules
run: git submodule update --init --recursive --force

Expand Down Expand Up @@ -44,6 +44,43 @@ jobs:
sudo update-ca-certificates
cp -f /etc/ssl/certs/ca-certificates.crt core/src/foss/golang/clash/component/ca/ca-certificates.crt

- name: Read and increment version from build.gradle.kts
id: process-version
run: |
# read version from build.gradle.kts
VERSION_NAME=$(grep -oP 'versionName\s*=\s*"\K[^"]+' build.gradle.kts)
VERSION_CODE=$(grep -oP 'versionCode\s*=\s*\K\d+' build.gradle.kts)

echo "Current version: $VERSION_NAME ($VERSION_CODE)"

# increment version
IFS='.' read -ra VERSION_PARTS <<< "$VERSION_NAME"
VERSION_PARTS[2]=$((VERSION_PARTS[2] + 1))
NEW_VERSION_NAME="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
NEW_VERSION_CODE=$((VERSION_CODE + 1))

echo "New version: $NEW_VERSION_NAME ($NEW_VERSION_CODE)"

echo "versionName=$NEW_VERSION_NAME" >> $GITHUB_OUTPUT
echo "versionCode=$NEW_VERSION_CODE" >> $GITHUB_OUTPUT

- name: Update build.gradle.kts with new version
run: |
sed -i "s/versionName = \".*\"/versionName = \"${{ steps.process-version.outputs.versionName }}\"/" build.gradle.kts
sed -i "s/versionCode = .*/versionCode = ${{ steps.process-version.outputs.versionCode }}/" build.gradle.kts

- name: Local Properties
env:
CUSTOM_APPLICATION_ID: ${{ secrets.CUSTOM_APPLICATION_ID }}
REMOVE_SUFFIX: ${{ secrets.REMOVE_SUFFIX }}
run: |
touch local.properties
echo custom.application.id="$CUSTOM_APPLICATION_ID" >> local.properties
echo remove.suffix="$REMOVE_SUFFIX" >> local.properties

echo "cat local.properties"
cat local.properties

- name: Signing properties
env:
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
Expand Down
26 changes: 19 additions & 7 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
release-tag:
description: 'Release Tag (v2.x.x)'
description: "Release Tag (v2.x.x)"
required: true

jobs:
Expand All @@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Checkout submodules
run: git submodule update --init --recursive --force

Expand All @@ -41,26 +41,26 @@ jobs:
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/[email protected]
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: |
Expand All @@ -83,6 +83,18 @@ jobs:
sudo update-ca-certificates
cp -f /etc/ssl/certs/ca-certificates.crt core/src/foss/golang/clash/component/ca/ca-certificates.crt

- name: Local Properties
env:
CUSTOM_APPLICATION_ID: ${{ secrets.CUSTOM_APPLICATION_ID }}
REMOVE_SUFFIX: ${{ secrets.REMOVE_SUFFIX }}
run: |
touch local.properties
echo custom.application.id="$CUSTOM_APPLICATION_ID" >> local.properties
echo remove.suffix="$REMOVE_SUFFIX" >> local.properties

echo "cat local.properties"
cat local.properties

- name: Signing properties
env:
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
Expand Down Expand Up @@ -124,4 +136,4 @@ jobs:
"ignore_labels": [
"Update"
],
}
}
Loading