Build, Test and Snapshot Release #1
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 and Snapshot Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: '0 0 * * 0' # Weekly on Sunday at midnight | |
| workflow_dispatch: # Allows manual triggering | |
| jobs: | |
| build: | |
| name: Build and Test on All Platforms | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| go-version: [1.20] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Install dependencies | |
| run: go mod tidy | |
| - name: Lint Go files | |
| run: go fmt ./... | |
| - name: Run tests | |
| run: go test ./... -v | |
| - name: Build binary | |
| run: | | |
| mkdir -p dist | |
| GOOS=$(echo ${{ matrix.os }} | cut -d'-' -f1) | |
| GOARCH=amd64 | |
| go build -o dist/cf-cli-java-plugin-${GOOS}-${GOARCH} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: cf-cli-java-plugin-${{ matrix.os }} | |
| path: dist/ | |
| release: | |
| name: Create Snapshot Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' || github.event_name == 'schedule' | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: cf-cli-java-plugin-${{ matrix.os }} | |
| path: dist/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: dist/* | |
| prerelease: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |