merge: resolve version conflict, keep 2.1.2 #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| 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 | |
| fetch-tags: true | |
| - name: Checkout submodules | |
| run: git submodule update --init --recursive --force | |
| - name: Fetch submodule tags | |
| run: git -C core/src/foss/golang/clash fetch --force --tags origin | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: 21 | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: "1.26" | |
| check-latest: true # Always check for the latest patch release | |
| - name: Apply Patches | |
| run: | | |
| cd $(go env GOROOT) | |
| for p in $GITHUB_WORKSPACE/.github/patch/*.patch; do patch --verbose -p 1 < "$p"; done | |
| - 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: | | |
| if [ -n "${{ inputs.release-tag }}" ]; then | |
| # Manual trigger: use the provided tag | |
| VERSION_TAG=${{ inputs.release-tag }} | |
| else | |
| # Push trigger: read version from build.gradle.kts | |
| VERSION_TAG="v$(grep 'versionName' build.gradle.kts | head -1 | sed 's/.*"\(.*\)".*/\1/')" | |
| fi | |
| 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 "versionName=$VERSION_TAG" >> $GITHUB_OUTPUT # "1.2.3" | |
| echo "versionCode=$VERSION_CODE" >> $GITHUB_OUTPUT # "102003" | |
| echo "versionTag=v$VERSION_TAG" >> $GITHUB_OUTPUT # "v1.2.3" | |
| # Re-write version in build.gradle.kts (only for manual trigger with new tag) | |
| - name: Re-write version | |
| if: ${{ inputs.release-tag != '' }} | |
| uses: Devofure/advance-android-version-actions@v1.5 | |
| with: | |
| gradlePath: build.gradle.kts | |
| versionCode: ${{ steps.process-version.outputs.versionCode }} | |
| versionName: ${{ steps.process-version.outputs.versionName }} | |
| # If any change found, commit it and push | |
| - name: Commit and push if changes | |
| if: ${{ inputs.release-tag != '' }} | |
| run: | | |
| changes=$(git diff --name-only | wc -l) | |
| if [ $changes -gt 0 ] | |
| then | |
| newVersionName=${{ steps.process-version.outputs.versionName }} | |
| newVersionCode=${{ steps.process-version.outputs.versionCode }} | |
| 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: Update CA | |
| run: | | |
| sudo apt-get update && sudo apt-get install ca-certificates | |
| sudo update-ca-certificates | |
| cp -f /etc/ssl/certs/ca-certificates.crt core/src/foss/golang/clash/component/ca/ca-certificates.crt | |
| - name: Setup signing (keystore) | |
| env: | |
| KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} | |
| run: | | |
| echo "$KEYSTORE_BASE64" | base64 -d > release.keystore | |
| - 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 "remove.suffix=true" >> local.properties | |
| echo "Signing properties configured" | |
| - name: Release Build | |
| if: success() | |
| run: ./gradlew --no-daemon app:assembleMetaRelease | |
| - name: Tag Repo | |
| uses: richardsimko/update-tag@v1 | |
| with: | |
| tag_name: ${{ steps.process-version.outputs.versionTag }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload Release | |
| uses: softprops/action-gh-release@v1 | |
| if: ${{ success() }} | |
| with: | |
| tag_name: ${{ steps.process-version.outputs.versionTag }} | |
| 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" | |
| ], | |
| } |