Skip to content

Commit

Permalink
Merge pull request #11 from jcchavezs/publish_on_release
Browse files Browse the repository at this point in the history
chore: publish artifact on release.
  • Loading branch information
jcchavezs authored Feb 23, 2024
2 parents 00240e4 + 6c30a05 commit f5a5429
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
31 changes: 30 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,48 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check out code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true

- name: Install tinygo
uses: acifani/setup-tinygo@v1
with:
tinygo-version: ${{ env.TINYGO_VERSION }}

- name: Build wasm binary
run: go run mage.go build

- name: Run tests
run: go run mage.go test

- name: Run e2e tests
run: go run mage.go e2e

- name: Create draft release
# Triggered only on tag creation and if release does not exist
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
run: |
set +e
tag="${GITHUB_REF#refs/tags/}"
if ! gh release view ${tag}; then
echo "Release ${tag} does not exist, creating..."
gh release create ${tag} --draft --title ${GITHUB_REF#refs/tags/}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Push build artifact to release
# Triggered only on tag creation
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
run: |
tag="${GITHUB_REF#refs/tags/}"
zip -j build/coraza-http-wasm-${tag}.zip build/coraza-http-wasm.wasm
gh release upload ${tag} ./build/coraza-http-wasm-${tag}.zip --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48 changes: 48 additions & 0 deletions .github/workflows/nightly-coraza-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Nightly Coraza Check
on:
pull_request:
paths:
- ".github/workflows/nightly-coraza-check.yaml"
- ".github/workflows/ci.yaml"
schedule:
- cron: "0 4 * * *"

env:
GO_VERSION: "1.21.x"
TINYGO_VERSION: "0.30.0"

jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true

- name: Install tinygo
uses: acifani/setup-tinygo@v1
with:
tinygo-version: ${{ env.TINYGO_VERSION }}

- name: Get last commit of coraza
id: coraza-latest-commit
run: echo "value=$(gh api repos/corazawaf/coraza/commits/main -q .sha)" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Fetch last coraza version
run: go get -u github.com/corazawaf/coraza/v3@${{ steps.coraza-latest-commit.outputs.value }} && go mod tidy

- name: Build binary
run: go run mage.go build

- name: Run tests
run: go run mage.go test

- name: Run e2e tests
run: go run mage.go e2e

0 comments on commit f5a5429

Please sign in to comment.