From 1be94a7171cd1e26d9becd8752abe6e5527d8c52 Mon Sep 17 00:00:00 2001 From: LTFan Date: Sat, 20 Jan 2024 18:18:39 +0800 Subject: [PATCH] ci: ci --- .github/workflows/build-and-release.yaml | 90 ++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/build-and-release.yaml diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml new file mode 100644 index 0000000..96adcea --- /dev/null +++ b/.github/workflows/build-and-release.yaml @@ -0,0 +1,90 @@ +name: Build and Release + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: write + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - platform: Android, Linux, Web + os: ubuntu-latest + command: | + chmod +x gradlew + ./gradlew ciVersioning + ./gradlew ciReleaseLinuxApp + - platform: Windows + os: windows-latest + command: | + gradlew ciVersioning + gradlew ciReleaseWindowsApp + + name: Build and Release ${{ matrix.platform }} on ${{ matrix.os }} + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup JDK + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + + - if: matrix.os == 'ubuntu-latest' + name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y dpkg rpm + + - if: matrix.os == 'ubuntu-latest' + name: Configure Android signing + shell: bash + run: | + if [ "${{ secrets.KEY }}" != "" ] && [ "${{ secrets.PROPERTIES }}" != "" ]; then + cd composeApp + echo ${{ secrets.KEY }} | base64 --decode > key.jks + echo ${{ secrets.PROPERTIES }} | base64 --decode > key.properties + fi + + - name: Build ${{ matrix.platform }} app + id: build + run: | + ${{ matrix.command }} + + - if: github.ref == 'refs/heads/main' && github.event_name == 'push' + name: Create tag + uses: actions/github-script@v7 + with: + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/v${{ steps.build.outputs.version }}', + sha: context.sha + }) + + - if: github.ref == 'refs/heads/main' && github.event_name == 'push' + name: Release + uses: svenstaro/upload-release-action@v2 + with: + file: build/assets/*