From 3a5a216ba3ee345f8add21ed4e5d3634195cdd43 Mon Sep 17 00:00:00 2001 From: Jagandeep Brar Date: Thu, 31 Mar 2022 20:52:00 -0400 Subject: [PATCH] chore(ci): build and publish Linux builds to Snapcraft --- .github/workflows/prepare_build.yml | 24 +++++ .github/workflows/release.yml | 17 ++++ .github/workflows/release_android.yml | 3 + .github/workflows/release_ios.yml | 3 + .github/workflows/release_linux.yml | 126 ++++++++++++++++++++++++++ .github/workflows/release_macos.yml | 3 + .github/workflows/release_web.yml | 4 + 7 files changed, 180 insertions(+) create mode 100644 .github/workflows/release_linux.yml diff --git a/.github/workflows/prepare_build.yml b/.github/workflows/prepare_build.yml index 58e67de6..519fd061 100644 --- a/.github/workflows/prepare_build.yml +++ b/.github/workflows/prepare_build.yml @@ -14,6 +14,9 @@ on: number: description: "Build Number" value: ${{ jobs.number.outputs.output1 }} + version: + description: "Build Version" + value: ${{ jobs.version.outputs.output1 }} jobs: flavor: @@ -90,3 +93,24 @@ jobs: run: | echo ${{ steps.script.outputs.result }} echo "::set-output name=number::${{ steps.script.outputs.result }}" + + version: + name: Version + runs-on: ubuntu-latest + outputs: + output1: ${{ steps.output.outputs.number }} + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Get Version + id: version + uses: martinbeentjes/npm-get-version-action@v1.1.0 + + - name: Set Output + id: output + run: | + echo ${{ steps.version.outputs.current-version }} + echo "::set-output name=number::${{ steps.version.outputs.current-version }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f2a4d969..9ecc9dfd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,6 +55,7 @@ jobs: with: build_flavor: ${{ needs.prepare_build.outputs.flavor }} build_number: ${{ needs.prepare_build.outputs.number }} + build_version: ${{ needs.prepare_build.outputs.version }} secrets: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} @@ -69,6 +70,7 @@ jobs: with: build_flavor: ${{ needs.prepare_build.outputs.flavor }} build_number: ${{ needs.prepare_build.outputs.number }} + build_version: ${{ needs.prepare_build.outputs.version }} secrets: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} @@ -84,6 +86,19 @@ jobs: MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} MATCH_SSH_PRIVATE_KEY: ${{ secrets.MATCH_SSH_PRIVATE_KEY }} + linux: + name: Linux + needs: [ prepare_build, validate ] + uses: JagandeepBrar/LunaSea/.github/workflows/release_linux.yml@master + with: + build_flavor: ${{ needs.prepare_build.outputs.flavor }} + build_number: ${{ needs.prepare_build.outputs.number }} + build_version: ${{ needs.prepare_build.outputs.version }} + secrets: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} + SNAPCRAFT_TOKEN: ${{ secrets.SNAPCRAFT_TOKEN }} + macos: name: macOS needs: [ prepare_build, validate ] @@ -91,6 +106,7 @@ jobs: with: build_flavor: ${{ needs.prepare_build.outputs.flavor }} build_number: ${{ needs.prepare_build.outputs.number }} + build_version: ${{ needs.prepare_build.outputs.version }} secrets: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ITC_TEAM_ID: ${{ secrets.APPLE_ITC_TEAM_ID }} @@ -113,6 +129,7 @@ jobs: with: build_flavor: ${{ needs.prepare_build.outputs.flavor }} build_number: ${{ needs.prepare_build.outputs.number }} + build_version: ${{ needs.prepare_build.outputs.version }} secrets: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} diff --git a/.github/workflows/release_android.yml b/.github/workflows/release_android.yml index 3d7310be..3a3e3b4f 100644 --- a/.github/workflows/release_android.yml +++ b/.github/workflows/release_android.yml @@ -9,6 +9,9 @@ on: build_number: required: true type: string + build_version: + required: true + type: string secrets: DISCORD_WEBHOOK: diff --git a/.github/workflows/release_ios.yml b/.github/workflows/release_ios.yml index 5dc9b339..de12f5f1 100644 --- a/.github/workflows/release_ios.yml +++ b/.github/workflows/release_ios.yml @@ -9,6 +9,9 @@ on: build_number: required: true type: string + build_version: + required: true + type: string secrets: APPLE_ID: diff --git a/.github/workflows/release_linux.yml b/.github/workflows/release_linux.yml new file mode 100644 index 00000000..a1166450 --- /dev/null +++ b/.github/workflows/release_linux.yml @@ -0,0 +1,126 @@ +name: '[Release] Linux' + +on: + workflow_call: + inputs: + build_flavor: + required: true + type: string + build_number: + required: true + type: string + build_version: + required: true + type: string + + secrets: + DISCORD_WEBHOOK: + required: true + FIREBASE_OPTIONS: + required: true + SNAPCRAFT_TOKEN: + required: true + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Download Source Files + uses: actions/download-artifact@v2 + with: + name: lib-${{ github.sha }} + path: ${{ github.workspace }}/lib + + - name: Download Localization Files + uses: actions/download-artifact@v2 + with: + name: localization-${{ github.sha }} + path: ${{ github.workspace }}/assets/localization + + - name: Install Secrets + working-directory: ${{ github.workspace }} + run: | + echo ${{ secrets.FIREBASE_OPTIONS }} | base64 --decode > lib/firebase_options.dart + + - name: Install Snapcraft + uses: samuelmeuli/action-snapcraft@v1 + with: + use_lxd: true + + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + cache: true + cache-key: ${{ github.sha }} + + - name: Setup Flutter + working-directory: ${{ github.workspace }} + run: | + flutter pub get + + - name: Build LunaSea + working-directory: ${{ github.workspace }} + run: | + sg lxd -c 'snapcraft --use-lxd' + + - name: Upload Snap Build Artifact + uses: actions/upload-artifact@v2 + with: + name: linux-${{ inputs.build_flavor }}-${{ github.sha }} + path: ${{ github.workspace }}/lunasea_${{ inputs.build_version }}_amd64.snap + + - name: Send Discord Message + uses: sarisia/actions-status-discord@v1 + if: always() + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + with: + title: '`[${{ inputs.build_flavor }}]` Linux Build' + description: linux-${{ inputs.build_flavor }}-${{ github.sha }} + + deploy: + name: Deploy + runs-on: ubuntu-latest + needs: [ build ] + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Determine Release Channel + id: channel + uses: actions/github-script@v6 + env: + FLAVOR: ${{ inputs.ref }} + with: + result-encoding: string + script: | + const ref = process.env.FLAVOR || "edge"; + switch (ref) { + case "beta": return "beta"; + case "candidate": return "candidate"; + case "stable": return "stable"; + case "edge": + default: return "edge"; + } + + - name: Install Snapcraft + uses: samuelmeuli/action-snapcraft@v1 + with: + snapcraft_token: ${{ secrets.SNAPCRAFT_TOKEN }} + + - name: Download Snap Build Artifact + uses: actions/download-artifact@v2 + with: + name: linux-${{ inputs.build_flavor }}-${{ github.sha }} + path: ${{ github.workspace }} + + - name: Deploy to Snapcraft + run: | + snapcraft upload --release=${{ inputs.build_flavor }} lunasea_${{ inputs.build_version }}_amd64.snap diff --git a/.github/workflows/release_macos.yml b/.github/workflows/release_macos.yml index 2cb217dc..64712c32 100644 --- a/.github/workflows/release_macos.yml +++ b/.github/workflows/release_macos.yml @@ -9,6 +9,9 @@ on: build_number: required: true type: string + build_version: + required: true + type: string secrets: APPLE_ID: diff --git a/.github/workflows/release_web.yml b/.github/workflows/release_web.yml index 8f9c8715..865a75ca 100644 --- a/.github/workflows/release_web.yml +++ b/.github/workflows/release_web.yml @@ -9,6 +9,9 @@ on: build_number: required: true type: string + build_version: + required: true + type: string secrets: DISCORD_WEBHOOK: @@ -115,4 +118,5 @@ jobs: NETLIFY_SITE_ID: ${{ steps.channel.outputs.result }} with: publish-dir: ${{ github.workspace}}/build/web + production-deploy: true deploy-message: ${{ github.sha }}