Skip to content

ci: working? ci

ci: working? ci #1

Workflow file for this run

name: CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]
permissions:
contents: read
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
check-latest: true
- name: Download dependencies
run: go mod download
- name: Download rustic binaries
run: make download-rustic
- name: Run tests
run: go test -race -coverprofile=coverage.out ./...
- name: Upload coverage
uses: codecov/codecov-action@v4
if: always()
with:
file: ./coverage.out
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build:
name: Build
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
goos: [linux]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
check-latest: true
- name: Download rustic binaries
run: make download-rustic
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
VERSION=$(git describe --tags --always --dirty)
go build -v -trimpath \
-ldflags="-s -w -X github.com/pyrohost/elytra/src/system.Version=${VERSION}" \
-o dist/elytra_${{ matrix.goos }}_${{ matrix.goarch }} \
./src/cmd/elytra
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: elytra-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/elytra_${{ matrix.goos }}_${{ matrix.goarch }}
retention-days: 7
compression-level: 0
docker-dev:
name: Docker (dev)
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: read
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download rustic binaries
run: make download-rustic
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/pyrohost/elytra
tags: |
type=ref,event=branch,suffix=-dev
type=sha,prefix={{branch}}-dev-
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: VERSION=dev-${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: true
sbom: true