Skip to content

refactor: translate comments and documentation to improve clarity for… #8

refactor: translate comments and documentation to improve clarity for…

refactor: translate comments and documentation to improve clarity for… #8

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Build frontend
run: |
cd web
npm ci
npm run build
- name: Download dependencies
run: go mod download
- name: Build binaries for multiple platforms
run: |
mkdir -p dist
# Linux AMD64
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/tjudge-api-linux-amd64 ./cmd/api
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/tjudge-worker-linux-amd64 ./cmd/worker
# Linux ARM64
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/tjudge-api-linux-arm64 ./cmd/api
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/tjudge-worker-linux-arm64 ./cmd/worker
# macOS AMD64
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/tjudge-api-darwin-amd64 ./cmd/api
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/tjudge-worker-darwin-amd64 ./cmd/worker
# macOS ARM64
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/tjudge-api-darwin-arm64 ./cmd/api
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/tjudge-worker-darwin-arm64 ./cmd/worker
# Windows AMD64
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/tjudge-api-windows-amd64.exe ./cmd/api
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/tjudge-worker-windows-amd64.exe ./cmd/worker
- name: Create checksums
run: |
cd dist
sha256sum * > checksums.txt
- name: Generate changelog
id: changelog
run: |
# Get previous tag
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
echo "First release, no previous tag found"
echo "changelog=Initial release" >> $GITHUB_OUTPUT
else
# Generate changelog from commits
CHANGELOG=$(git log --pretty=format:"- %s (%h)" $PREV_TAG..HEAD)
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: softprops/action-gh-release@v1
with:
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
generate_release_notes: true
body: |
## What's Changed
${{ steps.changelog.outputs.changelog }}
## Docker Images
```
ghcr.io/${{ github.repository_owner }}/tjudge-api:${{ github.ref_name }}
ghcr.io/${{ github.repository_owner }}/tjudge-worker:${{ github.ref_name }}
ghcr.io/${{ github.repository_owner }}/tjudge-executor:${{ github.ref_name }}
```
## Checksums
See checksums.txt in release assets.
files: |
dist/*
update-docs:
name: Update Documentation
needs: release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Update version in README
env:
VERSION: ${{ github.ref_name }}
run: |
# Update Go version badge if needed (no-op if pattern doesn't match)
sed -i "s/Go-[0-9.]*+-00ADD8/Go-1.24+-00ADD8/g" README.md || true
- name: Commit changes
env:
VERSION: ${{ github.ref_name }}
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add -A
git diff --quiet && git diff --staged --quiet || git commit -m "docs: update version to $VERSION"
git push || true