test: checkout code first, to use the go.mod file #60
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
--- | |
name: Package Build | |
on: | |
push: | |
branches: | |
- '**' | |
tags: | |
- 'v*.*.*' | |
jobs: | |
build: | |
strategy: | |
matrix: | |
arch: [ amd64, arm64 ] | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
- name: Print Go version and environment | |
id: vars | |
run: | | |
printf "Using go at: $(which go)\n" | |
printf "Go version: $(go version)\n" | |
printf "\n\nGo environment:\n\n" | |
go env | |
printf "\n\nSystem environment:\n\n" | |
env | |
SEMVER_RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z\.-]*\)' | |
echo TAG_MAJOR=`echo ${TAG#v} | sed -e "s#$SEMVER_RE#\1#"` >> $GITHUB_ENV | |
echo TAG_MINOR=`echo ${TAG#v} | sed -e "s#$SEMVER_RE#\2#"` >> $GITHUB_ENV | |
echo TAG_PATCH=`echo ${TAG#v} | sed -e "s#$SEMVER_RE#\3#"` >> $GITHUB_ENV | |
echo TAG_SPECIAL=`echo ${TAG#v} | sed -e "s#$SEMVER_RE#\4#"` >> $GITHUB_ENV | |
if [[ $GITHUB_REF_TYPE == "branch" ]]; then | |
echo "PACKAGE_VERSION=$(date +%Y%m%d%H%M)-${GITHUB_SHA:0:7}" >> $GITHUB_ENV | |
else | |
echo "PACKAGE_VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV | |
fi | |
- name: Install dependencies | |
run: | | |
sudo apt update && sudo apt -y install make pkg-config rubygems && sudo gem install fpm | |
- name: Build binary | |
run: VERSION=${PACKAGE_VERSION} ARCH=${{ matrix.arch }} go run mage.go build | |
- name: Build package | |
run: | | |
fpm -s dir -t deb -a ${{ matrix.arch }} -n coraza-spoa -v $PACKAGE_VERSION \ | |
--description "Coraza HAProxy SPOA" \ | |
--url "https://www.coraza.io" \ | |
--maintainer "OWASP Coraza Team" \ | |
--license Apache-2.0 \ | |
--vendor OWASP \ | |
--after-install ./contrib/coraza-spoa.postinst \ | |
--deb-systemd ./contrib/coraza-spoa.service \ | |
--deb-systemd-enable \ | |
--config-files /etc/coraza-spoa/config.yaml \ | |
./build/coraza-spoa=/usr/bin/coraza-spoa \ | |
./LICENSE=/usr/share/doc/coraza-spoa/ \ | |
./example/coraza-spoa.yaml=/etc/coraza-spoa/config.yaml | |
## Publish to the "testing" repo | |
- name: Cloudsmith Push:debian/coraza-spoa-snapshots | |
if: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }} | |
uses: cloudsmith-io/action@master | |
with: | |
api-key: ${{ secrets.CLOUDSMITH_API_KEY }} | |
command: "push" | |
format: "deb" | |
owner: "corazawaf" # Your Cloudsmith account name or org name (namespace) | |
repo: "coraza-spoa-snapshots" # Your Cloudsmith Repository name (slug) | |
distro: "any-distro" # Your Distribution (i.e Debian, Ubuntu) | |
release: "any-version" # Your Distribution Release (i.e xenial, buster) | |
file: "coraza-spoa_${PACKAGE_VERSION}_${{matrix.arch}}.deb" # debian package filename | |
## Publish tags to the "main" repo | |
- name: Cloudsmith Push:debian/coraza-spoa | |
if: ${{ github.ref_type == 'tag' }} | |
uses: cloudsmith-io/action@master | |
with: | |
api-key: ${{ secrets.CLOUDSMITH_API_KEY }} | |
command: "push" | |
format: "deb" | |
owner: "corazawaf" # Your Cloudsmith account name or org name (namespace) | |
repo: "coraza-spoa" # Your Cloudsmith Repository name (slug) | |
distro: "any-distro" # Your Distribution (i.e Debian, Ubuntu) | |
release: "any-version" # Your Distribution Release (i.e xenial, buster) | |
file: "coraza-spoa_${PACKAGE_VERSION}_${{matrix.arch}}.deb" # debian package filename | |
#- name: cloudsmith/rpm | |
# id: cloudsmith-rpm | |
# uses: cloudsmith-io/action@master | |
# with: | |
# api-key: ${{ secrets.CLOUDSMITH_API_KEY }} | |
# command: "push" | |
# format: "rpm" | |
# owner: "ono" # Your Cloudsmith account name or org name (namespace) | |
# repo: "coraza-spoa" # Your Cloudsmith Repository name (slug) | |
# distro: "any-distro" # Your Distribution (i.e el, fedora) | |
# release: "any-distro" # Your Distribution Release (i.e 7, 32) | |
# republish: "true" # needed ONLY if version is not changing | |
# file: "YOUR-FILENAME.rpm" #rpm package filename |