name: Release on: workflow_dispatch: push: tags: ["v*"] jobs: release: runs-on: ubuntu-latest steps: - name: Checkout uses: https://github.com/actions/checkout@v4 with: fetch-depth: 0 - name: Resolve version metadata id: version shell: bash run: | SHOULD_RUN=true POINTED_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -n1)" if [[ "${GITHUB_REF}" == refs/heads/main ]] && [[ -n "$POINTED_TAG" ]]; then SHOULD_RUN=false VERSION="$POINTED_TAG" elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then VERSION="${GITHUB_REF_NAME}" else VERSION="$(git describe --tags)" fi echo "should_run=$SHOULD_RUN" >> "$GITHUB_OUTPUT" echo "version=$VERSION" >> "$GITHUB_OUTPUT" if [[ "$VERSION" =~ ^v[0-9]+(\.[0-9]+)*$ ]]; then echo "is_prerelease=false" >> "$GITHUB_OUTPUT" else echo "is_prerelease=true" >> "$GITHUB_OUTPUT" fi - name: Set up Node.js if: steps.version.outputs.should_run == 'true' uses: https://github.com/actions/setup-node@v4 with: node-version: 20 - name: Build Frontend if: steps.version.outputs.should_run == 'true' env: CI: "" VERSION: ${{ steps.version.outputs.version }} run: | cd atsf_server/web corepack enable pnpm install --frozen-lockfile NEXT_PUBLIC_APP_VERSION="$VERSION" pnpm build - name: Set up Go if: steps.version.outputs.should_run == 'true' uses: https://github.com/actions/setup-go@v5 with: go-version-file: atsf_server/go.mod - name: Build Server Binaries if: steps.version.outputs.should_run == 'true' shell: bash env: CGO_ENABLED: 0 VERSION: ${{ steps.version.outputs.version }} run: | set -euo pipefail mkdir -p dist cd atsf_server go mod download while read -r GOOS GOARCH ASSET_NAME; do GOOS="$GOOS" GOARCH="$GOARCH" \ go build -trimpath -ldflags "-s -w -X 'atsflare/common.Version=$VERSION'" -o "../dist/$ASSET_NAME" . done <<'EOF' linux amd64 atsflare-server-linux-amd64 linux arm64 atsflare-server-linux-arm64 darwin amd64 atsflare-server-darwin-amd64 darwin arm64 atsflare-server-darwin-arm64 windows amd64 atsflare-server-windows-amd64.exe EOF - name: Build Agent Binaries if: steps.version.outputs.should_run == 'true' shell: bash env: CGO_ENABLED: 0 VERSION: ${{ steps.version.outputs.version }} run: | set -euo pipefail cd atsf_agent go mod download while read -r GOOS GOARCH ASSET_NAME; do GOOS="$GOOS" GOARCH="$GOARCH" \ go build -trimpath -ldflags "-s -w -X 'atsflare-agent/internal/config.AgentVersion=$VERSION'" -o "../dist/$ASSET_NAME" ./cmd/agent done <<'EOF' linux amd64 atsflare-agent-linux-amd64 linux arm64 atsflare-agent-linux-arm64 darwin amd64 atsflare-agent-darwin-amd64 darwin arm64 atsflare-agent-darwin-arm64 windows amd64 atsflare-agent-windows-amd64.exe EOF - name: Publish Release if: steps.version.outputs.should_run == 'true' uses: https://gitea.com/actions/gitea-release-action@v1 with: tag_name: ${{ steps.version.outputs.version }} name: ${{ steps.version.outputs.version }} target_commitish: ${{ github.sha }} files: | dist/* draft: false prerelease: ${{ steps.version.outputs.is_prerelease == 'true' }}