Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new(ci): added a release workflow. #46

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Generate release body for published releases
on:
release:
types: [published]

# Checks if any concurrent jobs is running for driver release CI and eventually wait for it.
concurrency:
group: release
cancel-in-progress: false

jobs:
release-settings:
runs-on: ubuntu-latest
outputs:
is_latest: ${{ steps.get_settings.outputs.is_latest }}
steps:
- name: Get latest release
uses: rez0n/actions-github-release@27a57820ee808f8fd940c8a9d1f7188f854aa2b5 # v2.0
id: latest_release
env:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
type: "stable"

- name: Get settings for this release
id: get_settings
shell: python
run: |
import os
import re
import sys

semver_no_meta = '''^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'''
tag_name = '${{ github.event.release.tag_name }}'

is_valid_version = re.match(semver_no_meta, tag_name) is not None
if not is_valid_version:
print(f'Release version {tag_name} is not a valid full or pre-release. See RELEASE.md for more information.')
sys.exit(1)

is_prerelease = '-' in tag_name

# Safeguard: you need to both set "latest" in GH and not have suffixes to overwrite latest
is_latest = '${{ steps.latest_release.outputs.release }}' == tag_name and not is_prerelease

with open(os.environ['GITHUB_OUTPUT'], 'a') as ofp:
print(f'is_latest={is_latest}'.lower(), file=ofp)

release-body-libs:
needs: [release-settings]
if: ${{ needs.release-settings.outputs.is_latest == 'true' }} # only for latest releases
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

# This will also download libs internal plugin api files
- name: Build
run: make -j4

- name: Create release body file
run: |
touch release-body.md

- name: Extract FALCOSECURITY_LIBS_REVISION
run: |
FALCOSECURITY_LIBS_REVISION=$(grep FALCOSECURITY_LIBS_REVISION Makefile | head -n1 | awk -F '\?= ' '{print $2}')
echo '!'"[LIBS_REVISION](https://img.shields.io/badge/LIBS_REVISION-${FALCOSECURITY_LIBS_REVISION}-yellow)" >> release-body.md

- name: Extract plugin API version
run: |
PLUGIN_API_MAJ=$(grep PLUGIN_API_VERSION_MAJOR include/falcosecurity/internal/deps/plugin_api.h | head -n1 | awk -F ' ' '{print $3}')
PLUGIN_API_MIN=$(grep PLUGIN_API_VERSION_MINOR include/falcosecurity/internal/deps/plugin_api.h | head -n1 | awk -F ' ' '{print $3}')
PLUGIN_API_PATCH=$(grep PLUGIN_API_VERSION_PATCH include/falcosecurity/internal/deps/plugin_api.h | head -n1 | awk -F ' ' '{print $3}')
PLUGIN_API_VERS="${PLUGIN_API_MAJ}.${PLUGIN_API_MIN}.${PLUGIN_API_PATCH}"
echo '!'"[PLUGIN_API](https://img.shields.io/badge/PLUGIN_API-${PLUGIN_API_VERS}-yellow)" >> release-body.md
echo "" >> release-body.md

- name: Generate release notes
uses: leodido/rn2md@9c351d81278644c0e17b1ca68edbdba305276c73
with:
milestone: ${{ github.event.release.tag_name }}
output: ./notes.md

- name: Merge release notes to pre existent body
run: cat notes.md >> release-body.md

- name: Attach release creator to release body
run: |
echo "" >> release-body.md
echo "#### Release Manager @${{ github.event.release.author.login }}" >> release-body.md

- name: Release
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # v2.2.0
with:
body_path: ./release-body.md
tag_name: ${{ github.event.release.tag_name }}
name: ${{ github.event.release.name }}
Loading