Skip to content

Github Actions Release Example

Eduardo M edited this page Aug 3, 2022 · 2 revisions

Here is an example workflow that can be used to for Updat, this comes from https://github.com/fluttertools/sidekick/blob/main/.github/workflows/release.yml:

on:
  release:
    types: # This configuration does not affect the page_build event above
      - created

name: Release Artifacts

jobs:
  build-linux:
    name: "Build Linux"
    runs-on: ubuntu-18.04
    timeout-minutes: 30
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - uses: actions/[email protected]

      - name: Setup Flutter SDK
        uses: subosito/[email protected]
        with:
          channel: "stable"

      - name: Install Linux build tools
        run: sudo apt-get update && sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev libblkid-dev liblzma-dev

      - name: Enable desktop
        run: flutter config --enable-linux-desktop

      - name: Install Cider
        run: flutter pub global activate cider

      - name: Set new Flutter version
        run: cider version ${{ github.event.release.tag_name }}

      - name: Set Sidekick.desktop version
        uses: DamianReeves/[email protected]
        with:
          path: Sidekick.desktop
          contents: Version=${{ github.event.release.tag_name }}
          write-mode: append

      - name: Set Sidekick.desktop version (snap version)
        uses: DamianReeves/[email protected]
        with:
          path: snap/gui/sidekick.desktop
          contents: Version=${{ github.event.release.tag_name }}
          write-mode: append

      - name: Set snapcraft.yaml version
        uses: DamianReeves/[email protected]
        with:
          path: snap/snapcraft.yaml
          contents: 'version: "${{ github.event.release.tag_name }}"'
          write-mode: append

      - name: Set release changelog
        run: cider release

      - name: Flutter get packages
        run: flutter pub get

      - name: Build Runner & version
        run: flutter pub run build_runner build --delete-conflicting-outputs

      - name: Flutter build app
        run: flutter build linux

      - name: Compress artifacts
        uses: TheDoctor0/[email protected]
        with:
          filename: linux-${{ github.event.release.tag_name }}.zip

      - name: Upload files to a GitHub release
        uses: svenstaro/[email protected]
        with:
          # GitHub token.
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          # Local file to upload.
          file: linux-${{ github.event.release.tag_name }}.zip
          # Tag to use as a release.
          tag: ${{ github.ref }}

      - name: Build AppImage
        uses: AppImageCrafters/build-appimage@master
        with:
          recipe: "AppImageBuilder.yml"

      - name: Upload AppImage to release
        uses: svenstaro/[email protected]
        with:
          # GitHub token.
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          # Local file to upload.
          file: Sidekick-latest-x86_64.AppImage
          asset_name: sidekick-linux-${{ github.event.release.tag_name }}.AppImage
          # Tag to use as a release.
          tag: ${{ github.ref }}

  build-macos:
    name: "Build MacOS"
    runs-on: macos-latest
    timeout-minutes: 30
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - uses: actions/[email protected]

      - name: Setup Flutter SDK
        uses: subosito/[email protected]
        with:
          channel: "stable"

      - name: Set Up XCode
        uses: devbotsxyz/[email protected]

      - name: Install create-dmg
        run: brew install create-dmg

      - name: Enable desktop
        run: flutter config --enable-macos-desktop

      - name: Install Cider
        run: flutter pub global activate cider

      - name: Set new Flutter version
        run: cider version ${{ github.event.release.tag_name }}

      - name: Set release changelog
        run: cider release

      - name: Flutter get packages
        run: flutter pub get

      - name: Build Runner & version
        run: flutter pub run build_runner build --delete-conflicting-outputs

      - name: Flutter build app
        run: flutter build macos

      - name: Create dmg
        run: |
          ./scripts/create_mac_dmg.sh
      - name: Compress artifacts
        run: zip -r macos-${{ github.event.release.tag_name }}.zip build/macos/Build/Products/Release

      - name: Upload artifacts to release
        uses: svenstaro/[email protected]
        with:
          # GitHub token.
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          # Local file to upload.
          file: macos-${{ github.event.release.tag_name }}.zip
          # Tag to use as a release.
          tag: ${{ github.ref }}

      - name: Upload DMG to release
        uses: svenstaro/[email protected]
        with:
          # GitHub token.
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          # Local file to upload.
          file: build/macos/Build/Products/Release/Sidekick.dmg
          asset_name: sidekick-macos-${{ github.event.release.tag_name }}.dmg
          # Tag to use as a release.
          tag: ${{ github.ref }}

  build-windows:
    name: "Build Windows standard"
    runs-on: windows-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - uses: actions/[email protected]

      - name: Setup Flutter SDK
        uses: subosito/[email protected]
        with:
          channel: "stable"

      - name: Enable desktop
        run: flutter config --enable-windows-desktop

      - name: Install Cider
        run: flutter pub global activate cider

      - name: Set new Flutter version
        run: cider version ${{ github.event.release.tag_name }}

      - name: Set release changelog
        run: cider release

      - name: Generate MSIX-compatible version
        uses: ashley-taylor/[email protected]
        id: msixver
        with:
          value: ${{ github.event.release.tag_name }}
          regex: (\-\w+)|(\+\w+)
          replacement: ""

      - name: Write MSIX
        uses: DamianReeves/[email protected]
        with:
          path: pubspec.yaml
          contents: |
            msix_config:
              display_name: Sidekick
              publisher_display_name: Eduardo M.
              identity_name: 44484EduardoM.SidekickFlutter
              publisher: CN=1E781C91-227E-4505-B5B8-7E5EFE39D3A6
              msix_version: ${{steps.msixver.outputs.value }}.0
              logo_path: assets\promo-windows\icon.png
              architecture: x64
              capabilities: "internetClient,removableStorage"
              certificate_path: windows\SIDEKICK-CERT.pfx
              certificate_password: ${{ secrets.WIN_CERT_PASS }}
              store: false
          write-mode: append

      - name: Flutter get packages
        run: flutter pub get

      - name: Build Runner & version
        run: flutter pub run build_runner build --delete-conflicting-outputs

      - name: Flutter build app
        run: flutter build windows

      - name: Create MSIX
        run: flutter pub run msix:create

      - name: Compress artifacts
        run: tar.exe -a -c -f windows-${{ github.event.release.tag_name }}.zip build/windows/Runner/release

      - name: Upload artifacts to release
        uses: svenstaro/[email protected]
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          file: windows-${{ github.event.release.tag_name }}.zip
          tag: ${{ github.ref }}

      - name: Upload MSIX to release
        uses: svenstaro/[email protected]
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          file: build/windows/Runner/release/sidekick.msix
          asset_name: sidekick-windows-${{ github.event.release.tag_name }}.msix
          tag: ${{ github.ref }}
Clone this wiki locally