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:

GitHub Actions

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 .desktop version
        uses: DamianReeves/[email protected]
        with:
          path: APPNAME.desktop
          contents: Version=${{ github.event.release.tag_name }}
          write-mode: append

      - name: Set .desktop version (snap version)
        uses: DamianReeves/[email protected]
        with:
          path: snap/gui/APPNAME.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: APPNAME-latest-x86_64.AppImage
          asset_name: appname-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/APPNAME.dmg
          asset_name: appname-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: APPNAME
              publisher_display_name: PUB
              identity_name: PUB
              publisher: PUB
              msix_version: ${{steps.msixver.outputs.value }}.0
              logo_path: assets\promo-windows\icon.png
              architecture: x64
              capabilities: "internetClient,removableStorage"
              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/appname.msix
          asset_name: appname-windows-${{ github.event.release.tag_name }}.msix
          tag: ${{ github.ref }}

Linux

AppImageBuilder.yml

version: 1
script:
  - rm -rf ./AppDir || true
  - cp -r ./build/linux/x64/release/bundle ./AppDir
  - mkdir -p ./AppDir/usr/share/icons/hicolor/64x64/apps/
  - cp ./snap/gui/APPNAME.png ./AppDir/usr/share/icons/hicolor/64x64/apps/
AppDir:
  path: ./AppDir
  app_info:
    id: app.fvm.appname
    name: appname
    icon: appname
    version: latest
    exec: appname
    exec_args: $@
  apt:
    arch: amd64
    allow_unauthenticated: true
    sources:
      - sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
      - sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
      - sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
      - sourceline: deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
    include:
      - libgtk-3-0
    exclude:
      - humanity-icon-theme
      - hicolor-icon-theme
      - adwaita-icon-theme
      - ubuntu-mono
  files:
    exclude:
      - usr/share/man
      - usr/share/doc/*/README.*
      - usr/share/doc/*/changelog.*
      - usr/share/doc/*/NEWS.*
      - usr/share/doc/*/TODO.*
  test:
    fedora:
      image: appimagecrafters/tests-env:fedora-30
      command: ./AppRun
      use_host_x: true
    debian:
      image: appimagecrafters/tests-env:debian-stable
      command: ./AppRun
      use_host_x: true
    arch:
      image: appimagecrafters/tests-env:archlinux-latest
      command: ./AppRun
      use_host_x: true
    centos:
      image: appimagecrafters/tests-env:centos-7
      command: ./AppRun
      use_host_x: true
    ubuntu:
      image: appimagecrafters/tests-env:ubuntu-bionic
      command: ./AppRun
      use_host_x: true
AppImage:
  arch: x86_64
  update-information: guess
  sign-key: None

App.desktop

[Desktop Entry]
# This is a development .desktop file, no version is specified.
Terminal=false
Type=Application
Name=APPNAME
StartupWMClass=appname
Comment=COMMENTHERE
Exec=APPNAME%F
Icon=snap/gui/image.png
Categories=Utility;

snap/snapcraft.yaml

# This is a development snapcraft file, no version is specified. Uncomment the line below to build a snap.
#version: "0.1.0"
name: appname
summary: summary
description: |
 DESCRIPTION

confinement: strict
base: core18
grade: stable
icon: snap/gui/image.png

apps:
 appname:
   command: desktop-launch APPNAME
   extensions: [flutter-beta]
   plugs:
     - network
     - desktop
     - home

parts:
 appname:
   plugin: flutter
   flutter-target: lib/main.dart

snap/gui/Appname.desktop

[Desktop Entry]
# This is a development .desktop file, no version is specified.
Terminal=false
Type=Application
Name=APPNAME
Comment=DESCRIPTION
Exec=appname %f
Icon=${SNAP}/meta/gui/image.png
Categories=Utility;

MacOS

scripts/create_mac_dmg.sh

#!/bin/shell
test -f appname.dmg && rm appname.dmg
create-dmg \
  --volname "APPNAME Installer" \
  --volicon "./assets/appname_installer.icns" \
  --background "./assets/dmg_background.png" \
  --window-pos 200 120 \
  --window-size 800 530 \
  --icon-size 130 \
  --text-size 14 \
  --icon "APPNAME.app" 260 250 \
  --hide-extension "APPNAME.app" \
  --app-drop-link 540 250 \
  --hdiutil-quiet \
  "build/macos/Build/Products/Release/APPNAME.dmg" \
  "build/macos/Build/Products/Release/APPNAME.app"