Skip to content

feat: add JUnit XML output format for CI integration #3

feat: add JUnit XML output format for CI integration

feat: add JUnit XML output format for CI integration #3

Workflow file for this run

name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
ci:
uses: ./.github/workflows/ci.yml
release:
needs: ci
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: windows
goarch: amd64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
VERSION="${GITHUB_REF_NAME}"
EXT=""
if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi
BINARY="mdproof-${VERSION}-${GOOS}-${GOARCH}${EXT}"
go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o "${BINARY}" ./cmd/mdproof
echo "BINARY=${BINARY}" >> "$GITHUB_ENV"
- name: Package
run: |
if echo "$BINARY" | grep -q '\.exe$'; then
ARCHIVE="${BINARY%.exe}.zip"
zip "${ARCHIVE}" "$BINARY"
else
ARCHIVE="${BINARY}.tar.gz"
tar czf "${ARCHIVE}" "$BINARY"
fi
echo "ARTIFACT=${ARCHIVE}" >> "$GITHUB_ENV"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT }}
path: ${{ env.ARTIFACT }}
publish:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate checksums
working-directory: dist
run: sha256sum * > checksums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: dist/*
homebrew:
needs: publish
runs-on: ubuntu-latest
steps:
- name: Get version
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"
- name: Download macOS tarballs and compute SHA256
run: |
BASE="https://github.com/runkids/mdproof/releases/download/v${VERSION}"
curl -fsSL "${BASE}/mdproof-v${VERSION}-darwin-arm64.tar.gz" -o darwin-arm64.tar.gz
curl -fsSL "${BASE}/mdproof-v${VERSION}-darwin-amd64.tar.gz" -o darwin-amd64.tar.gz
curl -fsSL "${BASE}/mdproof-v${VERSION}-linux-amd64.tar.gz" -o linux-amd64.tar.gz
curl -fsSL "${BASE}/mdproof-v${VERSION}-linux-arm64.tar.gz" -o linux-arm64.tar.gz
echo "SHA_DARWIN_ARM64=$(sha256sum darwin-arm64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_ENV"
echo "SHA_DARWIN_AMD64=$(sha256sum darwin-amd64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_ENV"
echo "SHA_LINUX_AMD64=$(sha256sum linux-amd64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_ENV"
echo "SHA_LINUX_ARM64=$(sha256sum linux-arm64.tar.gz | cut -d' ' -f1)" >> "$GITHUB_ENV"
- name: Update Homebrew formula
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
FORMULA=$(cat <<RUBY
class Mdproof < Formula
desc "Markdown-native test runner — write tests as Markdown, run them as real tests"
homepage "https://github.com/runkids/mdproof"
version "${VERSION}"
license "MIT"
on_macos do
if Hardware::CPU.arm?
url "https://github.com/runkids/mdproof/releases/download/v${VERSION}/mdproof-v${VERSION}-darwin-arm64.tar.gz"
sha256 "${SHA_DARWIN_ARM64}"
else
url "https://github.com/runkids/mdproof/releases/download/v${VERSION}/mdproof-v${VERSION}-darwin-amd64.tar.gz"
sha256 "${SHA_DARWIN_AMD64}"
end
end
on_linux do
if Hardware::CPU.arm?
url "https://github.com/runkids/mdproof/releases/download/v${VERSION}/mdproof-v${VERSION}-linux-arm64.tar.gz"
sha256 "${SHA_LINUX_ARM64}"
else
url "https://github.com/runkids/mdproof/releases/download/v${VERSION}/mdproof-v${VERSION}-linux-amd64.tar.gz"
sha256 "${SHA_LINUX_AMD64}"
end
end
def install
bin.install Dir["mdproof-*"].first => "mdproof"
end
test do
assert_match version.to_s, shell_output("#{bin}/mdproof --version")
end
end
RUBY
)
# Clone tap, update formula, push
git clone "https://x-access-token:${GH_TOKEN}@github.com/runkids/homebrew-tap.git" tap
mkdir -p tap/Formula
echo "$FORMULA" > tap/Formula/mdproof.rb
cd tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/mdproof.rb
git commit -m "mdproof ${VERSION}"
git push