Skip to content

Commit

Permalink
update(ci): fail on non-semver release
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Guerra <luca@guerra.sh>
Co-authored-by: Federico Di Pierro <nierro92@gmail.com>
  • Loading branch information
LucaGuerra and FedeDP committed May 10, 2023
1 parent 1c83531 commit 227252e
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
outputs:
is_latest: ${{ steps.get_settings.outputs.is_latest }}
bucket_suffix: ${{ steps.get_settings.outputs.bucket_suffix }}
should_publish: ${{ steps.get_settings.outputs.should_publish }}
steps:
- name: Get latest release
uses: rez0n/actions-github-release@v2.0
Expand All @@ -30,11 +29,15 @@ jobs:
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-]*))*))?$'''
tag_name = '${{ github.event.release.tag_name }}'
should_publish = re.match(semver_no_meta, tag_name) is not None
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
Expand All @@ -45,12 +48,10 @@ jobs:
with open(os.environ['GITHUB_OUTPUT'], 'a') as ofp:
print(f'is_latest={is_latest}'.lower(), file=ofp)
print(f'should_publish={should_publish}'.lower(), file=ofp)
print(f'bucket_suffix={bucket_suffix}', file=ofp)
build-packages:
needs: [release-settings]
if: ${{ needs.release-settings.outputs.should_publish == 'true' }}
uses: falcosecurity/falco/.github/workflows/reusable_build_packages.yaml@master
with:
arch: x86_64
Expand All @@ -59,7 +60,6 @@ jobs:

build-packages-arm64:
needs: [release-settings]
if: ${{ needs.release-settings.outputs.should_publish == 'true' }}
uses: falcosecurity/falco/.github/workflows/reusable_build_packages.yaml@master
with:
arch: aarch64
Expand All @@ -68,7 +68,6 @@ jobs:

publish-packages:
needs: [release-settings, build-packages, build-packages-arm64]
if: ${{ needs.release-settings.outputs.should_publish == 'true' }}
uses: falcosecurity/falco/.github/workflows/reusable_publish_packages.yaml@master
with:
bucket_suffix: ${{ needs.release-settings.outputs.bucket_suffix }}
Expand All @@ -78,7 +77,6 @@ jobs:
# Both build-docker and its arm64 counterpart require build-packages because they use its output
build-docker:
needs: [release-settings, build-packages, publish-packages]
if: ${{ needs.release-settings.outputs.should_publish == 'true' }}
uses: falcosecurity/falco/.github/workflows/reusable_build_docker.yaml@master
with:
arch: x86_64
Expand All @@ -90,7 +88,6 @@ jobs:

build-docker-arm64:
needs: [release-settings, build-packages, publish-packages]
if: ${{ needs.release-settings.outputs.should_publish == 'true' }}
uses: falcosecurity/falco/.github/workflows/reusable_build_docker.yaml@master
with:
arch: aarch64
Expand All @@ -102,7 +99,6 @@ jobs:

publish-docker:
needs: [release-settings, build-docker, build-docker-arm64]
if: ${{ needs.release-settings.outputs.should_publish == 'true' }}
uses: falcosecurity/falco/.github/workflows/reusable_publish_docker.yaml@master
secrets: inherit
with:
Expand Down

0 comments on commit 227252e

Please sign in to comment.