Skip to content

Commit

Permalink
ci: Release job after tag creations (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
M4tteoP authored May 3, 2023
1 parent 343bc84 commit 99cce88
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,17 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Create draft release
# Triggered only on tag creation
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
run: |
sudo apt install zip -y
ls build
mv build/main.wasm build/coraza-proxy-wasm.wasm
tag="${GITHUB_REF#refs/tags/}"
zip -j build/coraza-proxy-wasm-${tag}.zip build/coraza-proxy-wasm.wasm
./.github/workflows/release_notes.sh ${tag} > release-notes.txt
gh release create ${tag} --draft --notes-file release-notes.txt --title ${GITHUB_REF#refs/tags/} ./build/coraza-proxy-wasm-${tag}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42 changes: 42 additions & 0 deletions .github/workflows/release_notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh -ue
# Copyright The OWASP Coraza contributors
# SPDX-License-Identifier: Apache-2.0

#
# Highly inspired by https://github.com/tetratelabs/wazero/blob/main/.github/workflows/release_notes.sh
#
# This script generates the release notes for a specific release tag.
# .github/workflows/release_notes.sh v1.3.0

tag=$1
prior_tag=$(git tag -l 'v*'|sed "/${tag}/,+10d"|tail -1)
if [ -n "${prior_tag}" ]; then
range="${prior_tag}..${tag}"
else
range=${tag}
fi

git config log.mailmap true
changelog=$(git log --format='%h %s %aN, %(trailers:key=co-authored-by)' "${range}")

# strip the v off the tag name more shell portable than ${tag:1}
version=$(echo "${tag}" | cut -c2-100) || exit 1
cat <<EOF
coraza-proxy-wasm ${version}
TODO: classify the below into up to 4 major headings and the rest as bulleted items in other changes
The published release notes should only include the summary statement in this section.
${changelog}
## X packages
Don't forget to cite who was involved and why
## Other changes
TODO: don't add trivial things like fixing spaces or non-concerns like build glitches
* Z is now fixed thanks to Yogi Bear
EOF

0 comments on commit 99cce88

Please sign in to comment.