ci: use core CLI for QA and standardize workflows
- ci.yml: Download latest dev release, run `core go qa`, build matrix - release.yml: Use go-version-file, consistent artifact handling - dev-release.yml: Add checksums, cleaner version string - coverage.yml: Standardize setup-go version, add CLI verification All workflows now use: - go-version-file for consistent Go version - upload-artifact@v4 / download-artifact@v4 - Proper version injection via ldflags Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1afa35d3c6
commit
aeb852c5e5
4 changed files with 109 additions and 58 deletions
67
.github/workflows/ci.yml
vendored
67
.github/workflows/ci.yml
vendored
|
|
@ -2,23 +2,72 @@ name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ["main"]
|
branches: [dev, main]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: ["main"]
|
branches: [dev, main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.22
|
go-version-file: 'go.mod'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install system dependencies
|
||||||
run: go mod tidy
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev
|
||||||
|
|
||||||
- name: Run tests
|
- name: Download core CLI
|
||||||
run: go test ./...
|
run: |
|
||||||
|
curl -sL "https://github.com/host-uk/core/releases/download/dev/core-linux-amd64" -o core
|
||||||
|
chmod +x core
|
||||||
|
sudo mv core /usr/local/bin/core
|
||||||
|
core --version
|
||||||
|
|
||||||
|
- name: Run QA
|
||||||
|
run: core go qa
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
- goos: darwin
|
||||||
|
goarch: arm64
|
||||||
|
- goos: windows
|
||||||
|
goarch: amd64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: 'go.mod'
|
||||||
|
|
||||||
|
- name: Build CLI
|
||||||
|
env:
|
||||||
|
GOOS: ${{ matrix.goos }}
|
||||||
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
CGO_ENABLED: '0'
|
||||||
|
run: |
|
||||||
|
EXT=""
|
||||||
|
if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi
|
||||||
|
VERSION="${GITHUB_REF_NAME:-dev}-$(git rev-parse --short HEAD)"
|
||||||
|
go build -trimpath \
|
||||||
|
-ldflags="-s -w -X github.com/host-uk/core/pkg/cli.AppVersion=${VERSION}" \
|
||||||
|
-o core-${GOOS}-${GOARCH}${EXT} .
|
||||||
|
|
||||||
|
- name: Verify build
|
||||||
|
if: matrix.goos == 'linux'
|
||||||
|
run: |
|
||||||
|
chmod +x core-linux-amd64
|
||||||
|
./core-linux-amd64 --version
|
||||||
|
|
|
||||||
9
.github/workflows/coverage.yml
vendored
9
.github/workflows/coverage.yml
vendored
|
|
@ -13,14 +13,14 @@ jobs:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v6
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'go.mod'
|
||||||
|
|
||||||
- name: Setup Task
|
- name: Setup Task
|
||||||
uses: arduino/setup-task@v2
|
uses: arduino/setup-task@v2
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install system dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev
|
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev
|
||||||
|
|
@ -31,6 +31,9 @@ jobs:
|
||||||
task cli:build
|
task cli:build
|
||||||
echo "$(pwd)/bin" >> $GITHUB_PATH
|
echo "$(pwd)/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: Verify CLI
|
||||||
|
run: bin/core --version
|
||||||
|
|
||||||
- name: Run coverage
|
- name: Run coverage
|
||||||
run: task cov
|
run: task cov
|
||||||
|
|
||||||
|
|
@ -40,7 +43,7 @@ jobs:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
- name: Upload coverage report
|
- name: Upload coverage report
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: coverage-report
|
name: coverage-report
|
||||||
path: coverage.txt
|
path: coverage.txt
|
||||||
|
|
|
||||||
19
.github/workflows/dev-release.yml
vendored
19
.github/workflows/dev-release.yml
vendored
|
|
@ -33,8 +33,7 @@ jobs:
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.24'
|
go-version-file: 'go.mod'
|
||||||
check-latest: true
|
|
||||||
|
|
||||||
- name: Build CLI
|
- name: Build CLI
|
||||||
env:
|
env:
|
||||||
|
|
@ -45,10 +44,12 @@ jobs:
|
||||||
EXT=""
|
EXT=""
|
||||||
if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi
|
if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi
|
||||||
VERSION="dev-$(git rev-parse --short HEAD)"
|
VERSION="dev-$(git rev-parse --short HEAD)"
|
||||||
go build -trimpath -ldflags="-s -w -X github.com/host-uk/core/pkg/cli.AppVersion=${VERSION}" -o core-${GOOS}-${GOARCH}${EXT} .
|
go build -trimpath \
|
||||||
|
-ldflags="-s -w -X github.com/host-uk/core/pkg/cli.AppVersion=${VERSION}" \
|
||||||
|
-o core-${GOOS}-${GOARCH}${EXT} .
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: core-${{ matrix.goos }}-${{ matrix.goarch }}
|
name: core-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||||
path: core-*
|
path: core-*
|
||||||
|
|
@ -65,8 +66,11 @@ jobs:
|
||||||
path: artifacts
|
path: artifacts
|
||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
|
|
||||||
- name: List artifacts
|
- name: Generate checksums
|
||||||
run: ls -la artifacts/
|
run: |
|
||||||
|
cd artifacts
|
||||||
|
sha256sum core-* > CHECKSUMS.txt
|
||||||
|
cat CHECKSUMS.txt
|
||||||
|
|
||||||
- name: Delete existing dev release
|
- name: Delete existing dev release
|
||||||
env:
|
env:
|
||||||
|
|
@ -79,13 +83,12 @@ jobs:
|
||||||
- name: Create dev release
|
- name: Create dev release
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
COMMIT_SHA: ${{ github.sha }}
|
|
||||||
run: |
|
run: |
|
||||||
gh release create dev \
|
gh release create dev \
|
||||||
--title "Development Build" \
|
--title "Development Build" \
|
||||||
--notes "Latest development build from the dev branch.
|
--notes "Latest development build from the dev branch.
|
||||||
|
|
||||||
**Commit:** ${COMMIT_SHA}
|
**Commit:** ${{ github.sha }}
|
||||||
**Built:** $(date -u +'%Y-%m-%d %H:%M:%S UTC')
|
**Built:** $(date -u +'%Y-%m-%d %H:%M:%S UTC')
|
||||||
|
|
||||||
This is a pre-release for testing. Use tagged releases for production." \
|
This is a pre-release for testing. Use tagged releases for production." \
|
||||||
|
|
|
||||||
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
|
|
@ -33,27 +33,23 @@ jobs:
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.24'
|
go-version-file: 'go.mod'
|
||||||
check-latest: true
|
|
||||||
|
|
||||||
- name: Get version from tag
|
|
||||||
id: version
|
|
||||||
run: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Build CLI
|
- name: Build CLI
|
||||||
env:
|
env:
|
||||||
GOOS: ${{ matrix.goos }}
|
GOOS: ${{ matrix.goos }}
|
||||||
GOARCH: ${{ matrix.goarch }}
|
GOARCH: ${{ matrix.goarch }}
|
||||||
CGO_ENABLED: '0'
|
CGO_ENABLED: '0'
|
||||||
|
VERSION: ${{ github.ref_name }}
|
||||||
run: |
|
run: |
|
||||||
EXT=""
|
EXT=""
|
||||||
if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi
|
if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi
|
||||||
go build -trimpath \
|
go build -trimpath \
|
||||||
-ldflags="-s -w -X github.com/host-uk/core/pkg/cli.AppVersion=${{ steps.version.outputs.VERSION }}" \
|
-ldflags="-s -w -X github.com/host-uk/core/pkg/cli.AppVersion=${VERSION}" \
|
||||||
-o core-${GOOS}-${GOARCH}${EXT} .
|
-o core-${GOOS}-${GOARCH}${EXT} .
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: core-${{ matrix.goos }}-${{ matrix.goarch }}
|
name: core-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||||
path: core-*
|
path: core-*
|
||||||
|
|
@ -73,14 +69,14 @@ jobs:
|
||||||
- name: Generate checksums
|
- name: Generate checksums
|
||||||
run: |
|
run: |
|
||||||
cd artifacts
|
cd artifacts
|
||||||
sha256sum core-* > checksums.txt
|
sha256sum core-* > CHECKSUMS.txt
|
||||||
cat checksums.txt
|
cat CHECKSUMS.txt
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
gh release create ${{ github.ref_name }} \
|
gh release create ${{ github.ref_name }} \
|
||||||
--title "${{ github.ref_name }}" \
|
--title "Release ${{ github.ref_name }}" \
|
||||||
--generate-notes \
|
--generate-notes \
|
||||||
artifacts/*
|
artifacts/*
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue