Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 71 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,92 @@
name: CI

permissions:
contents: write

on:
push:
branches: [ main ]
tags: [ '*' ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
arch: [amd64, arm64]
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- name: Checkout
uses: actions/checkout@v4
with:
go-version: '1.25'
- name: Build
shell: bash
run: |
export GOARCH=${{ matrix.arch }}
if [[ "${{ runner.os }}" == "Windows" ]]; then
go build -o bin/scrubectl-${{ matrix.os }}-${{ matrix.arch }}.exe
else
go build -o bin/scrubectl-${{ matrix.os }}-${{ matrix.arch }}
fi
- name: Test
run: go test ./pkg/...
- name: Format
run: go fmt ./... && git diff --exit-code
- name: Upload artifact
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: './go.mod'

- name: Setup development environment
run: make setup

- name: Run tests
run: make test

- name: Run linter
run: make vet

- name: Generate coverage report
run: make test-coverage

- name: Upload coverage to artifacts
uses: actions/upload-artifact@v4
with:
name: scrubectl-${{ matrix.os }}-${{ matrix.arch }}
path: bin/scrubectl-${{ matrix.os }}-${{ matrix.arch }}*
release:
needs: build
name: coverage-report
path: coverage.html

build:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: test
steps:
- uses: actions/download-artifact@v4
with:
name: scrubectl-ubuntu-latest-amd64
path: ./artifacts
- uses: actions/download-artifact@v4
- name: Checkout
uses: actions/checkout@v4
with:
name: scrubectl-ubuntu-latest-arm64
path: ./artifacts
- uses: actions/download-artifact@v4
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v5
with:
name: scrubectl-macos-latest-amd64
path: ./artifacts
- uses: actions/download-artifact@v4
with:
name: scrubectl-macos-latest-arm64
path: ./artifacts
- uses: actions/download-artifact@v4
go-version-file: './go.mod'

- name: Setup development environment
run: make setup

- name: Build snapshot
run: make go-build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: scrubectl-windows-latest-amd64
path: ./artifacts
- uses: actions/download-artifact@v4
name: build-artifacts
path: dist/

release:
runs-on: ubuntu-latest
needs: [test, build]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
name: scrubectl-windows-latest-arm64
path: ./artifacts
- name: Publish release assets
uses: softprops/action-gh-release@v2
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v5
with:
files: artifacts/*
go-version-file: './go.mod'

- name: Setup development environment
run: make setup

- name: Create release
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
.bin/
72 changes: 72 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
project_name: scrubectl
version: 2

before:
hooks:
- go mod download
gomod:
env:
- GOPROXY=direct
builds:
- id: scrubectl
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- "386"
- amd64
- arm
- arm64
goarm64:
- v8.0
goamd64:
- v1
goarm:
- "6"
ignore:
- goos: darwin
goarch: "386"
- goos: windows
goarch: "386"
flags:
- -trimpath
ldflags:
- -s -w -X github.com/awslabs/scrubectl/cmd.version={{.Version}} -X github.com/awslabs/scrubectl/cmd.commit={{.FullCommit}} -X github.com/awslabs/scrubectl/cmd.date={{.Date}}

upx:
- enabled: true
ids: [scrubectl]
goos: [linux]
goarch: [arm, arm64, amd64]
compress: best
lzma: true
binary: .bin/upx

checksum:
name_template: "{{ .ProjectName }}_checksums.txt"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
- Merge pull request
- Merge branch
archives:
- name_template: >-
{{- .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end -}}
format_overrides:
- goos: windows
formats:
- zip
snapshot:
version_template: "{{ incpatch .Version }}-{{ .ShortCommit }}"
Loading