Build server on pr #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: Build and Comment PR Binary | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| # Permissions required to upload releases and write comments | |
| permissions: | |
| pull-requests: write | |
| jobs: | |
| build-and-comment: | |
| name: Build and Link Binary | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| # Example: Setting up Go (Change this to your specific language setup) | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "^1.21" | |
| - name: Build Binary | |
| run: | | |
| GOOS=windows GOARCH=amd64 go build -ldflags "-X main.version=`git tag --sort=-version:refname | head -n 1`" -o server-pr${{ github.event.pull_request.number }}.exe ./cmd/server | |
| # 1. Upload file safely as an artifact without creating tags | |
| - name: Upload Binary Artifact | |
| id: upload-step | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: server-pr${{ github.event.pull_request.number }}.exe | |
| path: server-pr${{ github.event.pull_request.number }}.exe | |
| archive: false | |
| retention-days: 7 | |
| # 2. Post or Update a comment containing the download instructions | |
| - name: Comment PR Link | |
| uses: thollander/actions-comment-pull-request@v3 | |
| with: | |
| comment-tag: pr_binary_download | |
| message: | | |
| **PR Test Binary Built Successfully!** | |
| You can download the compiled server directly from the GitHub artifact portal: | |
| Download [server-pr${{ github.event.pull_request.number }}.exe](${{ steps.upload-step.outputs.artifact-url }}) | |
| _Note: You must be logged into GitHub to access this link._ |