Fix Go code formatting to pass CI checks #3
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: Build | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.21' | |
| - name: Run tests | |
| run: go test ./internal | |
| - name: Run go vet | |
| run: go vet ./... | |
| - name: Run go fmt check | |
| run: | | |
| if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then | |
| echo "Go code is not formatted:" | |
| gofmt -s -l . | |
| exit 1 | |
| fi | |
| build: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| goos: [linux, windows, darwin] | |
| goarch: [amd64, arm64] | |
| exclude: | |
| - goos: windows | |
| goarch: arm64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.21' | |
| - name: Build binary | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| run: | | |
| mkdir -p dist | |
| if [ "$GOOS" = "windows" ]; then | |
| go build -o dist/git-presenter-${{ matrix.goos }}-${{ matrix.goarch }}.exe ./cmd/git-presenter | |
| else | |
| go build -o dist/git-presenter-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/git-presenter | |
| fi | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: git-presenter-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: dist/ | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v3 | |
| with: | |
| path: dist | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| dist/git-presenter-linux-amd64/git-presenter-linux-amd64 | |
| dist/git-presenter-linux-arm64/git-presenter-linux-arm64 | |
| dist/git-presenter-darwin-amd64/git-presenter-darwin-amd64 | |
| dist/git-presenter-darwin-arm64/git-presenter-darwin-arm64 | |
| dist/git-presenter-windows-amd64/git-presenter-windows-amd64.exe | |
| body: | | |
| ## Installation | |
| ### Linux (x86_64) | |
| ```bash | |
| wget https://github.com/pythonandchips/git-presenter/releases/download/${{ github.ref_name }}/git-presenter-linux-amd64 | |
| chmod +x git-presenter-linux-amd64 | |
| sudo mv git-presenter-linux-amd64 /usr/local/bin/git-presenter | |
| ``` | |
| ### Linux (ARM64) | |
| ```bash | |
| wget https://github.com/pythonandchips/git-presenter/releases/download/${{ github.ref_name }}/git-presenter-linux-arm64 | |
| chmod +x git-presenter-linux-arm64 | |
| sudo mv git-presenter-linux-arm64 /usr/local/bin/git-presenter | |
| ``` | |
| ### macOS (Intel) | |
| ```bash | |
| wget https://github.com/pythonandchips/git-presenter/releases/download/${{ github.ref_name }}/git-presenter-darwin-amd64 | |
| chmod +x git-presenter-darwin-amd64 | |
| sudo mv git-presenter-darwin-amd64 /usr/local/bin/git-presenter | |
| ``` | |
| ### macOS (Apple Silicon) | |
| ```bash | |
| wget https://github.com/pythonandchips/git-presenter/releases/download/${{ github.ref_name }}/git-presenter-darwin-arm64 | |
| chmod +x git-presenter-darwin-arm64 | |
| sudo mv git-presenter-darwin-arm64 /usr/local/bin/git-presenter | |
| ``` | |
| ### Windows (x86_64) | |
| Download `git-presenter-windows-amd64.exe` and add to your PATH. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |