Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 79 additions & 3 deletions .github/workflows/ci-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
pull_request:

permissions:
contents: write
contents: read

jobs:
ci:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -49,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
Expand Down Expand Up @@ -95,5 +97,79 @@ jobs:
body_path: ${{ env.RELEASE_NOTES_FILE }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.x'

- 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 }}