name: CI/CD on: push: branches: [main] tags: ['v*'] pull_request: branches: [main] jobs: # ── 1. 정적 분석 + 빌드 + 테스트 ────────────────────────────────────────── test: runs-on: windows-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: '1.25' cache: true - name: Vet run: go vet ./... - name: Build run: go build -ldflags="-H windowsgui -s -w" -o launcher.exe . - name: Test run: go test ./... -v # ── 2. Gitea Release 생성 + launcher.exe 업로드 (태그 push 시만) ────────── release: needs: test if: startsWith(github.ref, 'refs/tags/v') runs-on: windows-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: '1.25' cache: true - name: Build release binary run: | $version = "${{ github.ref_name }}" go build -ldflags="-H windowsgui -s -w -X main.version=$version" -o launcher.exe . - name: Create Gitea release & upload launcher.exe shell: pwsh run: | $version = "${{ github.ref_name }}" $repo = "${{ github.repository }}" $token = "${{ secrets.GITEA_TOKEN }}" $baseUrl = "https://git.tolelom.xyz/api/v1" $headers = @{ "Authorization" = "token $token" "Content-Type" = "application/json" } # 릴리즈 생성 $body = @{ tag_name = $version name = $version body = "Release $version" } | ConvertTo-Json -Compress $release = Invoke-RestMethod ` -Uri "$baseUrl/repos/$repo/releases" ` -Method Post ` -Headers $headers ` -Body $body # launcher.exe 업로드 $uploadHeaders = @{ "Authorization" = "token $token" "Content-Type" = "application/octet-stream" } $fileBytes = [System.IO.File]::ReadAllBytes("${{ github.workspace }}\launcher.exe") Invoke-RestMethod ` -Uri "$baseUrl/repos/$repo/releases/$($release.id)/assets?name=launcher.exe" ` -Method Post ` -Headers $uploadHeaders ` -Body $fileBytes