resolved comments #6
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 and Release | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| jobs: | ||
| check-version: | ||
| name: Check VERSION.txt updated in PR | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'pull_request' | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Ensure VERSION.txt is updated | ||
| run: | | ||
| git fetch origin main | ||
| CHANGED=$(git diff --name-only origin/main...HEAD) | ||
| if ! echo "$CHANGED" | grep -qx VERSION.txt; then | ||
| echo "Error: VERSION.txt must be updated in this pull request." | ||
| exit 1 | ||
| fi | ||
| build: | ||
| name: Build Go project | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: Set up Go | ||
| uses: actions/setup-go@v4 | ||
| with: | ||
| go-version: 1.20 | ||
| - name: Download dependencies | ||
| run: go mod tidy | ||
| - name: Build binary | ||
| run: go build -o listener | ||
| release: | ||
| - name: Check version | ||
| run: | | ||
| VERSION=$(cat VERSION.txt) | ||
| echo "version=$VERSION" >> $GITHUB_ENV | ||
| echo "Version: $VERSION" | ||
| - name: Create Tag | ||
| if: | | ||
| (github.event_name == 'push' && github.ref == 'refs/heads/main') || | ||
| (github.event_name == 'pull_request' && | ||
| github.event.action == 'closed' && | ||
| github.event.pull_request.merged == true && | ||
| github.event.pull_request.base.ref == 'main') | ||
| run: | | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
| git config --global user.name "github-actions[bot]" | ||
| git tag "v${{ env.version }}" | ||
| git push origin "v${{ env.version }}" | ||
| - name: Create GitHub Release | ||
| if: | | ||
| (github.event_name == 'push' && github.ref == 'refs/heads/main') || | ||
| (github.event_name == 'pull_request' && | ||
| github.event.action == 'closed' && | ||
| github.event.pull_request.merged == true && | ||
| github.event.pull_request.base.ref == 'main') | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: v${{ env.version }} | ||
| name: Release v${{ env.version }} | ||
| files: build/monitor.bpf.o | ||
| # generate_release_notes: true | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||