chore: refactor release workflows

This commit is contained in:
Gareth
2025-09-07 00:12:16 -07:00
parent 2f1627ec44
commit 899f30c9bb
4 changed files with 70 additions and 108 deletions

20
.github/workflows/release-preview.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Release Preview
on:
push:
branches: ["main"]
paths-ignore:
- "docs/**"
- "*.md"
pull_request:
branches: ["main"]
paths-ignore:
- "docs/**"
- "*.md"
workflow_dispatch:
jobs:
call-reusable-release:
uses: ./.github/workflows/reusable-release.yml
with:
snapshot: true

View File

@@ -3,94 +3,15 @@ name: Tagged Release
on:
push:
tags:
- "*"
- "v*.*.*"
workflow_dispatch:
permissions:
contents: write
jobs:
tagged-release:
name: "Tagged Release"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.24"
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_TOKEN }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: dist/*
tagged-release-installers:
name: Windows installers
needs: tagged-release
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: .
- name: Unzip artifacts and compile Inno Setup installers
shell: powershell
run: |
mkdir windows_installers
foreach ($arch in "x86_64", "arm64") {
$src = "backrest_Windows_$arch"
Expand-Archive ".\${src}.zip"
cp build\windows\* $src
& "c:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DArch=$arch ${src}\installer.iss
cp "$src\Output\*" windows_installers
}
- name: Upload Assets
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
./windows_installers/*
call-reusable-release:
uses: ./.github/workflows/reusable-release.yml
with:
snapshot: false
secrets: inherit

View File

@@ -1,26 +1,27 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Build Snapshot Release
name: Reusable Release Workflow
on:
push:
branches: ["main"]
paths-ignore:
- "docs/**"
- "*.md"
pull_request:
branches: ["main"]
paths-ignore:
- "docs/**"
- "*.md"
workflow_dispatch:
workflow_call:
inputs:
snapshot:
description: "Run as a snapshot release"
required: true
type: boolean
secrets:
DOCKERHUB_USERNAME:
required: false
DOCKERHUB_TOKEN:
required: false
HOMEBREW_GITHUB_TOKEN:
required: false
jobs:
build:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
@@ -40,24 +41,34 @@ jobs:
with:
version: 9
- name: Build
- name: Login to Docker Hub
if: ${{ !inputs.snapshot }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --snapshot --clean
args: ${{ inputs.snapshot && 'release --snapshot --clean' || 'release --clean' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_TOKEN }}
- name: Upload Artifacts
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: backrest-snapshot-builds
name: release-builds
path: |
dist/*.tar.gz
dist/*.zip
installer:
name: Windows installers
needs: [build]
needs: [goreleaser]
runs-on: windows-2022
steps:
@@ -69,7 +80,7 @@ jobs:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: backrest-snapshot-builds
name: release-builds
- name: Unzip artifacts and compile Inno Setup installers
shell: powershell
@@ -83,8 +94,16 @@ jobs:
cp "$src\Output\*" windows_installers
}
- name: Upload installers
- name: Upload Installers as Artifacts
if: ${{ inputs.snapshot }}
uses: actions/upload-artifact@v4
with:
name: backrest-snapshot-installers
path: windows_installers\*.exe
- name: Upload Installers to Release
if: ${{ !inputs.snapshot && startsWith(github.ref, 'refs/tags/') }}
uses: softprops/action-gh-release@v2
with:
files: |
./windows_installers/*

View File

@@ -42,6 +42,8 @@ jobs:
- name: Test
run: PATH=$(pwd):$PATH gotestsum ./... -- --race
test-webui: runs-on
test-win:
runs-on: windows-latest
steps: