-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a8ef27
commit b6add03
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Release Caddy Middleware | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' # Trigger when a tag matching v* is pushed (e.g., v1.0.0) | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-latest # Base build platform, we will do cross-compilation | ||
|
||
strategy: | ||
matrix: | ||
goos: [linux, windows, darwin] | ||
goarch: [amd64, arm64] | ||
exclude: | ||
- goos: windows | ||
goarch: arm64 # Windows on arm64 is not common, remove it. | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21' # Use your desired go version | ||
|
||
- name: Extract Tag Name | ||
id: extract_tag | ||
run: echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT | ||
|
||
- name: Build Binary | ||
env: | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
run: | | ||
GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags "-X 'github.com/fabriziosalmi/caddy-waf/middleware.ModuleVersion=${{ steps.extract_tag.outputs.TAG_NAME }}'" -o caddy-waf-${GOOS}-${GOARCH} | ||
tar czf caddy-waf-${GOOS}-${GOARCH}.tar.gz caddy-waf-${GOOS}-${GOARCH} | ||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: caddy-waf-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | ||
asset_name: caddy-waf-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | ||
asset_content_type: application/gzip | ||
|
||
create-release: | ||
runs-on: ubuntu-latest | ||
needs: build-and-release # Ensure all builds complete before creating release | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Create Release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref_name }} | ||
release_name: Release ${{ github.ref_name }} | ||
body: | | ||
This is a release of the Caddy WAF middleware version ${{ github.ref_name }}. Please download the appropriate binary for your OS/Architecture. | ||
draft: false | ||
prerelease: false |