# Publishes a release on Gitea: push a tag like v1.0.0. # Images go to the registry of the Gitea that runs this workflow, # //, for linux/amd64 and linux/arm64, tagged # with the version (1.0.0, 1.0) and latest. Desktop installers (Windows NSIS, # Linux deb, rpm and AppImage) are attached to the Gitea release for the tag, # which is made once every build has passed. Gitea has no hosted Mac runners, # so the macOS DMG is built by hand on a Mac (wails3 task darwin:package:dmg # in Desktop-App) and attached to the release afterwards. # # What the Gitea side needs: # - Runners with the labels ubuntu-latest (a Docker runner whose jobs can use # Docker, for the image builds) and windows-latest (a host runner with Git # Bash on the PATH and NSIS or Chocolatey). # - Secret REGISTRY_TOKEN: an access token with package write access, for the # account in variable REGISTRY_USER (the person who pushed the tag when # unset). # - Optional variables: REGISTRY (another registry host), DOCS_URL (where # Help → Documentation goes in the desktop app), and # DESKTOP_UPDATE_MANIFEST_URL with DESKTOP_UPDATE_PUBLIC_KEY (the desktop # update feed; without them the build never updates itself, see updates.go). name: Release on: push: tags: ["v*"] workflow_dispatch: inputs: version: description: Version to stamp into the binaries (e.g. 0.1.0-rc1); images are tagged with it required: true permissions: contents: write packages: write jobs: images: runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: # No docwell-db image: the stack runs a stock PocketBase # (tajniak81/pocketbase-docker-root) and docwell-server applies # Docwell's schema to it. - name: docwell-server context: . dockerfile: Server/Dockerfile - name: docwell-web context: . dockerfile: Web-App/Dockerfile - name: docwell-media context: . dockerfile: Media/Dockerfile - name: docwell context: . dockerfile: Docker-AIO/Dockerfile steps: - uses: actions/checkout@v4 - name: Version id: version run: | v="${{ inputs.version || github.ref_name }}" echo "value=${v#v}" >> "$GITHUB_OUTPUT" # Gitea's own registry has the server's address. A plain http server # means a plain http registry, which BuildKit must be told about. - name: Registry id: registry env: REGISTRY: ${{ vars.REGISTRY }} SERVER_URL: ${{ github.server_url }} OWNER: ${{ github.repository_owner }} run: | host="$REGISTRY" http=false if [ -z "$host" ]; then host="${SERVER_URL#*://}" case "$SERVER_URL" in http://*) http=true ;; esac fi host="${host%/}" echo "host=$host" >> "$GITHUB_OUTPUT" echo "http=$http" >> "$GITHUB_OUTPUT" echo "image=$host/$(echo "$OWNER" | tr '[:upper:]' '[:lower:]')/${{ matrix.name }}" >> "$GITHUB_OUTPUT" # docker login refuses a plain http registry unless the runner's Docker # daemon lists it, so the credentials go straight into the client config # that buildx reads. - name: Registry sign-in env: HOST: ${{ steps.registry.outputs.host }} USERNAME: ${{ vars.REGISTRY_USER || github.actor }} TOKEN: ${{ secrets.REGISTRY_TOKEN }} run: | if [ -z "$TOKEN" ]; then echo "::error::Set the REGISTRY_TOKEN secret (an access token with package write access)." exit 1 fi mkdir -p ~/.docker auth=$(printf '%s:%s' "$USERNAME" "$TOKEN" | base64 | tr -d '\n') printf '{"auths":{"%s":{"auth":"%s"}}}\n' "$HOST" "$auth" > ~/.docker/config.json - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 with: buildkitd-config-inline: | [registry."${{ steps.registry.outputs.host }}"] http = ${{ steps.registry.outputs.http }} - id: meta uses: docker/metadata-action@v5 with: images: ${{ steps.registry.outputs.image }} tags: | type=semver,pattern={{version}},value=${{ steps.version.outputs.value }} type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.value }} type=raw,value=${{ steps.version.outputs.value }},enable=${{ github.event_name == 'workflow_dispatch' }} type=raw,value=latest,enable=${{ github.event_name == 'push' && !contains(github.ref_name, '-') }} labels: | org.opencontainers.image.title=${{ matrix.name }} org.opencontainers.image.licenses=AGPL-3.0-or-later # The build cache lives next to the image, as its "buildcache" tag. - uses: docker/build-push-action@v6 with: context: ${{ matrix.context }} file: ${{ matrix.dockerfile }} platforms: ${{ matrix.platforms || 'linux/amd64,linux/arm64' }} push: true build-args: VERSION=${{ steps.version.outputs.value }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=${{ steps.registry.outputs.image }}:buildcache cache-to: type=registry,ref=${{ steps.registry.outputs.image }}:buildcache,mode=max desktop: strategy: fail-fast: false matrix: include: - os: windows runner: windows-latest task: windows:package files: Desktop-App/bin/*-installer.exe - os: linux runner: ubuntu-latest task: linux:create:deb linux:create:rpm linux:create:appimage files: | Desktop-App/bin/*.deb Desktop-App/bin/*.rpm Desktop-App/bin/*.AppImage runs-on: ${{ matrix.runner }} defaults: run: shell: bash env: GOWORK: "off" # Containers have no FUSE; linuxdeploy unpacks itself instead. APPIMAGE_EXTRACT_AND_RUN: "1" steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: "1.26" - uses: actions/setup-node@v4 with: node-version: 24 cache: npm - name: Version id: version run: | v="${{ inputs.version || github.ref_name }}" echo "value=${v#v}" >> "$GITHUB_OUTPUT" - name: Linux packaging dependencies if: matrix.os == 'linux' run: sudo apt-get update && sudo apt-get install -y libgtk-4-dev libwebkitgtk-6.0-dev libfuse2 rpm - name: NSIS if: matrix.os == 'windows' run: | if ! command -v makensis >/dev/null; then choco install nsis -y --no-progress fi echo "C:/Program Files (x86)/NSIS" >> "$GITHUB_PATH" - name: Wails CLI run: go install github.com/wailsapp/wails/v3/cmd/wails3@v3.0.0 - run: npm ci - name: Stamp the version working-directory: Desktop-App run: node build/set-version.mjs "${{ steps.version.outputs.value }}" - name: Package working-directory: Desktop-App run: | flags="-X main.version=${{ steps.version.outputs.value }}" if [ -n "${{ vars.DOCS_URL }}" ]; then flags="$flags -X main.docsURL=${{ vars.DOCS_URL }}" fi if [ -n "${{ vars.DESKTOP_UPDATE_MANIFEST_URL }}" ]; then flags="$flags -X main.updateManifestURL=${{ vars.DESKTOP_UPDATE_MANIFEST_URL }} -X main.updatePublicKey=${{ vars.DESKTOP_UPDATE_PUBLIC_KEY }}" fi wails3 task ${{ matrix.task }} EXTRA_LDFLAGS="$flags" # v3: v4 of the artifact actions refuses to run outside github.com. - uses: actions/upload-artifact@v3 with: name: desktop-${{ matrix.os }} path: ${{ matrix.files }} release: needs: [images, desktop] if: github.event_name == 'push' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: sparse-checkout: CHANGELOG.md sparse-checkout-cone-mode: false # Each artifact lands in dist//. - uses: actions/download-artifact@v3 with: path: dist # The release text is the tag's section of CHANGELOG.md ("## 0.3.0 — …" # up to the next "## "), empty when there is none. - name: Release notes env: TAG: ${{ github.ref_name }} run: | v="${TAG#v}" awk -v v="$v" ' /^## / { on = (index($0, "## " v " ") == 1 || $0 == "## " v); next } on' CHANGELOG.md > notes.md echo "$(wc -l < notes.md) lines of release notes for $v" # Gitea's release API; a release made earlier for this tag (by hand or # by a rerun) gets the files added instead of a second release. - name: Release env: API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} TOKEN: ${{ secrets.GITHUB_TOKEN }} TAG: ${{ github.ref_name }} run: | auth="Authorization: token $TOKEN" prerelease=false case "$TAG" in *-*) prerelease=true ;; esac id=$(curl -fsS -H "$auth" "$API/releases/tags/$TAG" | jq -r .id) || id="" if [ -z "$id" ]; then id=$(jq -n --arg tag "$TAG" --argjson pre "$prerelease" --rawfile body notes.md \ '{tag_name: $tag, name: $tag, body: $body, prerelease: $pre}' | curl -fsS -X POST -H "$auth" -H "Content-Type: application/json" -d @- "$API/releases" | jq -r .id) elif [ -s notes.md ]; then jq -n --rawfile body notes.md '{body: $body}' | curl -fsS -X PATCH -H "$auth" -H "Content-Type: application/json" -d @- "$API/releases/$id" > /dev/null fi for f in dist/*/*; do name=$(basename "$f") echo "Attaching $name" curl -fsS -X POST -H "$auth" -F "attachment=@$f" "$API/releases/$id/assets?name=$name" > /dev/null done