Skip to content
Merged
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
16 changes: 7 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,20 @@ jobs:

test:
name: Test
uses: EduardoNGomes/shared-workflows/.github/workflows/go-test-simple.yml@main

verify-build:
name: Verify build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: Set up Go
uses: actions/setup-go@v6
uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache-dependency-path: go.sum

- name: Run tests
run: go test ./...

- name: Run race detector
run: go test -race ./...

- name: Verify build
- name: Build application
run: go build -trimpath -ldflags="-s -w" -o /tmp/mdo ./cmd
145 changes: 7 additions & 138 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,144 +10,13 @@ permissions:
jobs:
test:
name: Test release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: EduardoNGomes/shared-workflows/.github/workflows/go-test-simple.yml@main

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache-dependency-path: go.sum

- name: Run tests
run: go test ./...

- name: Run race detector
run: go test -race ./...

build-cross:
name: Build ${{ matrix.goos }} ${{ matrix.goarch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
archive: mdo-linux-amd64.tar.gz
- goos: linux
goarch: arm64
archive: mdo-linux-arm64.tar.gz
- goos: windows
goarch: amd64
archive: mdo-windows-amd64.zip
- goos: windows
goarch: arm64
archive: mdo-windows-arm64.zip
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache-dependency-path: go.sum

- name: Build binary
env:
CGO_ENABLED: "0"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
mkdir -p dist/package
binary="mdo"
if [ "$GOOS" = "windows" ]; then binary="mdo.exe"; fi
go build -trimpath -ldflags="-s -w" -o "dist/package/$binary" ./cmd

- name: Package Linux binary
if: matrix.goos == 'linux'
working-directory: dist/package
run: tar -czf "../${{ matrix.archive }}" mdo

- name: Package Windows binary
if: matrix.goos == 'windows'
working-directory: dist/package
run: zip "../${{ matrix.archive }}" mdo.exe

- name: Upload binary package
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/${{ matrix.archive }}
if-no-files-found: error
retention-days: 1

build-macos:
name: Build macOS ${{ matrix.goarch }}
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
goarch: [amd64, arm64]
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache-dependency-path: go.sum

- name: Build binary
env:
CGO_ENABLED: "0"
GOOS: darwin
GOARCH: ${{ matrix.goarch }}
run: |
mkdir -p dist/package
go build -trimpath -ldflags="-s -w" -o dist/package/mdo ./cmd

- name: Sign binary ad-hoc
run: codesign --sign - --force dist/package/mdo

- name: Package binary
working-directory: dist/package
run: tar -czf "../mdo-darwin-${{ matrix.goarch }}.tar.gz" mdo

- name: Upload binary package
uses: actions/upload-artifact@v6
with:
name: darwin-${{ matrix.goarch }}
path: dist/mdo-darwin-${{ matrix.goarch }}.tar.gz
if-no-files-found: error
retention-days: 1

publish:
name: Attach binaries to release
runs-on: ubuntu-latest
needs: [test, build-cross, build-macos]
release:
name: Build and publish release
needs: test
permissions:
contents: write
steps:
- name: Download binary packages
uses: actions/download-artifact@v6
with:
path: dist
merge-multiple: true

- name: Generate checksums
working-directory: dist
run: sha256sum mdo-* > checksums.txt

- name: Upload release assets
uses: softprops/action-gh-release@v3
with:
files: |
dist/mdo-*.tar.gz
dist/mdo-*.zip
dist/checksums.txt
fail_on_unmatched_files: true
uses: EduardoNGomes/shared-workflows/.github/workflows/go-os-build.yml@main
with:
name: mdo