Release #4
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: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release (e.g., v1.0.0)' | |
| required: true | |
| type: string | |
| env: | |
| BINARY_NAME: ccswitch | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run tests | |
| run: make test | |
| - name: Determine version | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| else | |
| VERSION="${GITHUB_REF#refs/tags/}" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Create GoReleaser config | |
| run: | | |
| cat > .goreleaser.yaml << 'EOF' | |
| project_name: ccswitch | |
| builds: | |
| - id: ccswitch | |
| binary: ccswitch | |
| goos: | |
| - linux | |
| - darwin | |
| - windows | |
| goarch: | |
| - amd64 | |
| - arm64 | |
| ldflags: | |
| - -X github.com/ksred/ccswitch/internal/version.Version={{.Version}} | |
| - -X github.com/ksred/ccswitch/internal/version.Commit={{.Commit}} | |
| - -X github.com/ksred/ccswitch/internal/version.BuildTime={{.Date}} | |
| env: | |
| - CGO_ENABLED=0 | |
| archives: | |
| - id: ccswitch | |
| name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}" | |
| format: tar.gz | |
| format_overrides: | |
| - goos: windows | |
| format: zip | |
| checksum: | |
| name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt" | |
| release: | |
| mode: replace | |
| header: | | |
| ## ccswitch {{ .Version }} | |
| A friendly CLI tool for managing multiple git worktrees. | |
| ### Installation | |
| You can install ccswitch using the install script: | |
| ```bash | |
| curl -sSL https://raw.githubusercontent.com/ksred/ccswitch/main/install.sh | bash | |
| ``` | |
| Or download the binary for your platform from the assets below. | |
| EOF | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@v5 | |
| with: | |
| version: latest | |
| args: release --clean --skip-validate | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.version }} |