From 11fc295ac0680929594d366d220e0f19cccd98be Mon Sep 17 00:00:00 2001 From: ItsNotGoodName Date: Thu, 2 Nov 2023 15:42:03 -0700 Subject: [PATCH] build: sign android release apk --- .github/workflows/nightly.yml | 16 +++++++++++----- Makefile | 2 +- Taskfile.yml | 29 +++++++++++++++++++---------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 6a1c448..5d38a1e 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -7,12 +7,9 @@ on: jobs: nightly: - env: - GH_REPO: ${{ github.repository }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} permissions: contents: write - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v4 @@ -25,6 +22,9 @@ jobs: distribution: "temurin" java-version: "17" + - name: Set up zipalign and apksigner + run: sudo apt install -y zipalign apksigner + - name: Set up Node uses: actions/setup-node@v3 with: @@ -47,10 +47,16 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Build + env: + ANDROID_KEYSTORE: ${{ secrets.ANDROID_KEYSTORE }} + ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} run: task build - name: Publish + env: + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release delete nightly --yes || true git push origin :nightly || true - gh release create --prerelease --title "Nightly" --notes "" --target $GITHUB_SHA nightly dist/artifacts/* + gh release create --prerelease --title "Nightly $(date +'%Y-%m-%d')" --notes "" --target $GITHUB_SHA nightly dist/artifacts/* diff --git a/Makefile b/Makefile index 657a206..3102fec 100644 --- a/Makefile +++ b/Makefile @@ -64,5 +64,5 @@ tooling-webrpc: tooling-java: $(info Please install Java 17.) -tooling-taskfile: +tooling-task: go install github.com/go-task/task/v3/cmd/task@latest diff --git a/Taskfile.yml b/Taskfile.yml index 4292e90..d165f77 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -15,20 +15,29 @@ tasks: cmds: - mkdir -p dist - chmod +x gradlew - - ./gradlew build - - ./gradlew assembleDebug - - cp app/build/outputs/apk/debug/app-debug.apk ../dist/radiomuxplayer-debug.apk + - ./gradlew :app:assembleRelease -x test + - rm {{.RELEASE_DIR}}/app-release-unsigned-aligned.apk || true + - zipalign -v -p 4 {{.RELEASE_DIR}}/app-release-unsigned.apk {{.RELEASE_DIR}}/app-release-unsigned-aligned.apk + - echo $ANDROID_KEYSTORE | base64 --decode > my-release-key.jks + - apksigner sign --ks my-release-key.jks --ks-pass env:ANDROID_KEYSTORE_PASSWORD --out {{.RELEASE_DIR}}/app-release.apk {{.RELEASE_DIR}}/app-release-unsigned-aligned.apk + - apksigner verify {{.RELEASE_DIR}}/app-release.apk + - cp {{.RELEASE_DIR}}/app-release.apk ../dist/radiomuxplayer-release.apk + vars: + RELEASE_DIR: app/build/outputs/apk/release + env: + ANDROID_KEYSTORE: + ANDROID_KEYSTORE_PASSWORD: build-server: internal: true cmds: - go mod tidy - go generate ./... - - GOOS=linux GOARCH=amd64 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Linux_x86_64 {{.MAIN}} - - GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Linux_armv7 {{.MAIN}} - - GOOS=linux GOARCH=arm64 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Linux_arm64 {{.MAIN}} - - GOOS=darwin GOARCH=arm64 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Darwin_arm64 {{.MAIN}} - - GOOS=windows GOARCH=amd64 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Windows_x86_64.exe {{.MAIN}} + - GOOS=linux GOARCH=amd64 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Linux_x86_64 {{.MAIN_PACKAGE}} + - GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Linux_armv7 {{.MAIN_PACKAGE}} + - GOOS=linux GOARCH=arm64 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Linux_arm64 {{.MAIN_PACKAGE}} + - GOOS=darwin GOARCH=arm64 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Darwin_arm64 {{.MAIN_PACKAGE}} + - GOOS=windows GOARCH=amd64 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Windows_x86_64.exe {{.MAIN_PACKAGE}} env: CGO_ENABLED: 0 vars: @@ -42,7 +51,7 @@ tasks: BUILD_REPO_URL: "https://{{.PACKAGE_NAME}}" LDFLAGS: -s -w -X {{.BUILD_PACKAGE_NAME}}.Version={{.BUILD_VERSION}} -X {{.BUILD_PACKAGE_NAME}}.Commit={{.BUILD_COMMIT}} -X {{.BUILD_PACKAGE_NAME}}.Date={{.BUILD_DATE}} -X {{.BUILD_PACKAGE_NAME}}.RepoURL={{.BUILD_REPO_URL}} - MAIN: "{{.PACKAGE_NAME}}/cmd/radiomux" + MAIN_PACKAGE: "{{.PACKAGE_NAME}}/cmd/radiomux" checksum: internal: true @@ -57,7 +66,7 @@ tasks: - for: { var: FILES } cmd: cp ../{{.ITEM}} . - mkdir -p artifacts - - cp radiomuxplayer-debug.apk artifacts/ + - cp radiomuxplayer-release.apk artifacts/ - tar -czf artifacts/radiomux_Linux_x86_64.tar.gz radiomux_Linux_x86_64 {{.FILES}} - tar -czf artifacts/radiomux_Linux_armv7.tar.gz radiomux_Linux_armv7 {{.FILES}} - tar -czf artifacts/radiomux_Linux_arm64.tar.gz radiomux_Linux_arm64 {{.FILES}}