refactor: streamline workspace namespace handling with conversion fun… #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/Release | |
| on: | |
| push: | |
| branches: [main] | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| 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 | |
| - goos: windows | |
| goarch: arm64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25' | |
| - name: Set version | |
| id: version | |
| run: | | |
| if [[ "$GITHUB_REF" == refs/tags/* ]]; then | |
| echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=dev-${GITHUB_SHA::7}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| run: | | |
| OUTPUT=sgs-${{ matrix.goos }}-${{ matrix.goarch }} | |
| if [ "${{ matrix.goos }}" = "windows" ]; then | |
| OUTPUT="${OUTPUT}.exe" | |
| fi | |
| go build -ldflags "-X github.com/bacchus-snu/sgs-cli/internal/sgs.Version=${{ steps.version.outputs.version }}" \ | |
| -o ${OUTPUT} ./cmd/sgs | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sgs-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: sgs-* | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Collect binaries | |
| run: | | |
| mkdir -p release | |
| find artifacts -type f -name 'sgs-*' -exec cp {} release/ \; | |
| ls -la release/ | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release/* | |
| generate_release_notes: true |