From 0d500e0f576b6377d6750d4678f9e0a18bf65d2f Mon Sep 17 00:00:00 2001 From: Eduardo Gomes Date: Mon, 14 Sep 2026 20:54:12 -0300 Subject: [PATCH] ci: use shared test and release workflows --- .github/workflows/ci.yml | 16 ++-- .github/workflows/release.yml | 145 ++-------------------------------- 2 files changed, 14 insertions(+), 147 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 431cb4d..293c05d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7d4972..1e73b89 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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