123 lines
5.0 KiB
YAML
123 lines
5.0 KiB
YAML
name: Build Linux Application
|
|
|
|
# Only a release built through "Releases -> New Release" starts a build. A tag
|
|
# pushed with plain git does not publish a release and is therefore ignored.
|
|
on:
|
|
release:
|
|
types:
|
|
- published
|
|
|
|
env:
|
|
# Keep in sync with the other workflows and with `ac_web/Dockerfile`.
|
|
FLUTTER_VERSION: '3.44.9'
|
|
|
|
jobs:
|
|
linux:
|
|
runs-on: ubuntu-latest
|
|
# Same base image as the docker job, it already brings the tools the
|
|
# actions below expect (git, curl, unzip, node).
|
|
container:
|
|
image: catthehacker/ubuntu:act-latest
|
|
|
|
# The flutter project lives in a sub directory of the repository.
|
|
defaults:
|
|
run:
|
|
working-directory: ac_web
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://github.com/actions/checkout@v4
|
|
|
|
# The flutter tool runs git inside the workspace and inside its own sdk,
|
|
# and git refuses to work in directories it considers to belong to
|
|
# somebody else.
|
|
- name: Trust the workspace
|
|
run: git config --global --add safe.directory '*'
|
|
|
|
# Everything `flutter build linux` needs to compile the gtk runner.
|
|
- name: Install the linux desktop toolchain
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y --no-install-recommends \
|
|
clang cmake ninja-build pkg-config \
|
|
libgtk-3-dev liblzma-dev libstdc++-12-dev \
|
|
curl unzip xz-utils jq
|
|
|
|
# `subosito/flutter-action` cannot be used: it caches the sdk through
|
|
# `actions/cache@v5`, and the act-runner of this gitea instance only
|
|
# supports actions up to node20 ("runs.using ... got node24"). Unpacking
|
|
# the official archive does the same thing and pins the version exactly,
|
|
# just like `ac_web/Dockerfile` does.
|
|
- name: Set up Flutter
|
|
run: |
|
|
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz" \
|
|
| tar -xJ -C /opt
|
|
echo "/opt/flutter/bin" >> "$GITHUB_PATH"
|
|
|
|
- name: Show the flutter version
|
|
run: flutter --version
|
|
|
|
- name: Install dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Run tests
|
|
run: flutter test
|
|
|
|
- name: Build the linux application
|
|
run: flutter build linux --release
|
|
|
|
# The build produces a directory, not a single file: the executable next
|
|
# to the flutter engine and its data. It is packed so that the artifact
|
|
# keeps the executable bit.
|
|
- name: Pack the bundle
|
|
run: tar -czf ac_web-linux-x64-${{ github.ref_name }}.tar.gz -C build/linux/x64/release bundle
|
|
|
|
# The tarball hangs off the release itself, next to the apk of the
|
|
# android job, so it can be downloaded without a login and stays after
|
|
# the artifacts of the run have been pruned.
|
|
- name: Attach the bundle to the release
|
|
env:
|
|
# The token gitea creates for the run. If the instance hands out a
|
|
# read only token, put a personal access token with repository write
|
|
# access in a secret and use that instead.
|
|
TOKEN: ${{ github.token }}
|
|
run: |
|
|
# The act-runner executes `run` with sh (dash), not bash, so this
|
|
# script has to stay posix - `set -o pipefail` for example dies
|
|
# with "Illegal option -o pipefail" before anything else runs.
|
|
set -eu
|
|
|
|
api="${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
|
|
asset="ac_web-linux-x64-${{ github.ref_name }}.tar.gz"
|
|
|
|
# The release event carries the id; the lookup by tag is only there
|
|
# for a manual re-run of the job.
|
|
releaseId="${{ github.event.release.id }}"
|
|
if [ -z "$releaseId" ] || [ "$releaseId" = "null" ]; then
|
|
release=$(curl -fsSL -H "Authorization: token $TOKEN" \
|
|
"$api/releases/tags/${{ github.ref_name }}")
|
|
releaseId=$(printf '%s' "$release" | jq -r '.id')
|
|
fi
|
|
|
|
curl -fsSL -X POST \
|
|
-H "Authorization: token $TOKEN" \
|
|
-F "attachment=@$asset" \
|
|
"$api/releases/$releaseId/assets?name=$asset" > /dev/null
|
|
|
|
echo "Attached $asset to release $releaseId."
|
|
|
|
# @v3 on purpose: `upload-artifact@v4` bundles `@actions/artifact` v2,
|
|
# which refuses to run as soon as `GITHUB_SERVER_URL` is not github.com
|
|
# ("GHESNotSupportedError") -- and on this instance it is the gitea host.
|
|
# The check happens in the action itself, before any request, so it
|
|
# cannot be fixed on the gitea side. @v3 talks to the older artifact api
|
|
# gitea implements and still runs on node20, which the act-runner allows.
|
|
- name: Upload the bundle
|
|
uses: https://github.com/actions/upload-artifact@v3
|
|
with:
|
|
name: ac_web-linux-x64-${{ github.ref_name }}
|
|
# Artifact paths are relative to the repository, not to the
|
|
# working-directory above.
|
|
path: ac_web/ac_web-linux-x64-${{ github.ref_name }}.tar.gz
|
|
if-no-files-found: error
|