From b7480cbe5c6e407940e1892d2fca57d8ab21d447 Mon Sep 17 00:00:00 2001 From: Federico Nafria Date: Mon, 22 Sep 2025 10:47:48 +0200 Subject: [PATCH 1/3] feat: add nightly build workflow --- .github/workflows/ci-and-release.yml | 74 +++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-and-release.yml b/.github/workflows/ci-and-release.yml index 814a680..0bc9474 100644 --- a/.github/workflows/ci-and-release.yml +++ b/.github/workflows/ci-and-release.yml @@ -96,4 +96,76 @@ jobs: draft: false prerelease: false env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + nightly: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.24' + + - name: Tidy modules + run: go mod tidy + + - name: Run tests + run: go test -v ./... + + - name: Set up environment variables + run: | + echo "VERSION=nightly-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV + echo "RELEASE_NOTES_FILE=release-notes.md" >> $GITHUB_ENV + + - name: Generate release notes + run: | + echo "# Nightly Build" > $RELEASE_NOTES_FILE + echo "" >> $RELEASE_NOTES_FILE + echo "## Latest commit" >> $RELEASE_NOTES_FILE + git log --pretty=format:"- %s" -n 1 >> $RELEASE_NOTES_FILE + + - name: Build binaries + run: | + # Create dist directory + mkdir -p dist + + # Build for multiple platforms + GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.version=${VERSION}" -o dist/patt-linux-amd64 ./cmd/patt + GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X main.version=${VERSION}" -o dist/patt-linux-arm64 ./cmd/patt + GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X main.version=${VERSION}" -o dist/patt-darwin-amd64 ./cmd/patt + GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.version=${VERSION}" -o dist/patt-darwin-arm64 ./cmd/patt + GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X main.version=${VERSION}" -o dist/patt-windows-amd64.exe ./cmd/patt + GOOS=windows GOARCH=arm64 go build -ldflags="-s -w -X main.version=${VERSION}" -o dist/patt-windows-arm64.exe ./cmd/patt + + - name: Create checksums + run: | + cd dist + sha256sum * > checksums.txt + + - name: Delete old nightly release + uses: dev-drpr/delete-tag-and-release@v0.2.1 + with: + tag_name: nightly + delete_repo_tag: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + continue-on-error: true + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: | + dist/* + body_path: ${{ env.RELEASE_NOTES_FILE }} + name: Nightly Build + tag_name: nightly + draft: false + prerelease: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b14c6cdfdbf5388f69a1e4e45d86141e0f643add Mon Sep 17 00:00:00 2001 From: Federico Nafria Date: Mon, 22 Sep 2025 10:52:00 +0200 Subject: [PATCH 2/3] fix: adjust workflow permissions --- .github/workflows/ci-and-release.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-and-release.yml b/.github/workflows/ci-and-release.yml index 0bc9474..03f04a1 100644 --- a/.github/workflows/ci-and-release.yml +++ b/.github/workflows/ci-and-release.yml @@ -9,7 +9,7 @@ on: pull_request: permissions: - contents: write + contents: read jobs: ci: @@ -40,6 +40,8 @@ jobs: release: if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest + permissions: + contents: write steps: - name: Checkout uses: actions/checkout@v4 @@ -101,6 +103,8 @@ jobs: nightly: if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest + permissions: + contents: write steps: - name: Checkout uses: actions/checkout@v4 @@ -168,4 +172,4 @@ jobs: draft: false prerelease: true env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 7ca1e23d9a15e5c273d214928f242fafed88d392 Mon Sep 17 00:00:00 2001 From: Federico Nafria Date: Mon, 22 Sep 2025 10:53:59 +0200 Subject: [PATCH 3/3] fix: use go 1.24.x in workflow --- .github/workflows/ci-and-release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-and-release.yml b/.github/workflows/ci-and-release.yml index 03f04a1..1c064d0 100644 --- a/.github/workflows/ci-and-release.yml +++ b/.github/workflows/ci-and-release.yml @@ -24,7 +24,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.24' + go-version: '1.24.x' - name: Tidy modules run: go mod tidy @@ -51,7 +51,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.24' + go-version: '1.24.x' - name: Tidy modules run: go mod tidy @@ -114,7 +114,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.24' + go-version: '1.24.x' - name: Tidy modules run: go mod tidy