Skip to content

Commit

Permalink
Create release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziosalmi authored Jan 29, 2025
1 parent 1a8ef27 commit b6add03
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
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

0 comments on commit b6add03

Please sign in to comment.