Skip to content

Commit

Permalink
fixup! Move release logic to a new workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoerens committed Jul 21, 2023
1 parent bcfda51 commit 95c6b69
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 27 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ jobs:
export ORIGIN_MASTER_SHA=$(git rev-parse origin/master)
echo "origin_master_sha=$ORIGIN_MASTER_SHA" >> $GITHUB_OUTPUT
- name: Tag master
id: tag_version
- name: Create release tag
id: create_release_tag
if: ${{ steps.check_version_updated.outputs.updated == 'true'}}
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.PAT_MGOERENS }}
custom_tag: ${{ steps.check_version_in_PR.outputs.PR_version }}
tag_prefix: ""
commit_sha: ${{ steps.master_sha.outputs.origin_master_sha }}
Expand Down Expand Up @@ -252,4 +252,4 @@ jobs:
imageReference=quay.io/redhat-certification/chart-verifier
podman pull ${imageReference}:${{ steps.check_version_in_PR.outputs.PR_version }}
podman tag ${imageReference}:${{ steps.check_version_in_PR.outputs.PR_version }} ${imageReference}:latest
podman push ${imageReference}:latest
podman push ${imageReference}:latest
40 changes: 27 additions & 13 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,44 @@ name: create release on new tags
on:
push:
# Publish semver tags as releases.
tags: [ '*.*.*' ]
# [0-9]+.[0-9]+.[0-9]+
tags: '[0-9]+.[0-9]+.[0-9]+'

jobs:
build-and-push:

build-and-release:
name: Create GitHub release
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod

- name: Print tag to GITHUB_OUTPUT
id: get_tag
run: |
echo "release_version=${GITHUB_REF#refs/*/}" | tee -a $GITHUB_OUTPUT
- name: Build binary and make tarball
id: build_bin
run: |
make bin
tar -zcvf chart-verifier.tgz -C out/ chart-verifier
export TARBALL_PATH=$(realpath chart-verifier.tgz)
echo "tarball_path=$TARBALL_PATH"
TARBALL_NAME="chart-verifier.tgz-${{ steps.get_tag.outputs.release_version }}.tgz"
tar -zcvf $TARBALL_NAME -C out/ chart-verifier
export TARBALL_PATH=$(realpath $TARBALL_NAME)
echo "tarball_path=$TARBALL_PATH" | tee -a $GITHUB_OUTPUT
- name: Print tag to GITHUB_OUTPUT
id: get_tag
- name: Check that the tag matches the current version
id: check_tag_and_version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
release_version=${{ steps.get_tag.outputs.release_version }}
bin_version=$(out/chart-verifier version --as-data | jq -r .version)
if [[ "$release_version" != "$bin_version" ]]; then
echo "Binary version ($bin_version) doesn't match tag ($release_version)" && exit 1
fi
- name: Set up Python 3.x
uses: actions/setup-python@v2
Expand All @@ -42,14 +56,14 @@ jobs:
- name: Generate release body
id: release_body
run: ve1/bin/print-release-body
run: echo "release_body=$(ve1/bin/print-release-body)" | tee -a $GITHUB_OUTPUT

- name: Create the the release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_tag.outputs.RELEASE_VERSION }}
body: ${{ steps.release_body.outputs.PR_release_body }}
tag_name: ${{ steps.get_tag.outputs.release_version }}
body: ${{ steps.release_body.outputs.release_body }}
files: ${{ steps.build_bin.outputs.tarball_path }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
14 changes: 5 additions & 9 deletions scripts/src/release/releasebody.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@
from release import releasechecker
from utils import utils

def make_release_body(version, image_name, release_info):
def get_release_body(version, image_name, release_info):
"""Generate the body of the GitHub release"""
body = f"Chart verifier version {version} <br><br>Docker Image:<br>- {image_name}:{version}<br><br>"
body += "This version includes:<br>"
for info in release_info:
if info.startswith("<"):
body += info
else:
body += f"- {info}<br>"

print(f"[INFO] Release body: {body}")
utils.add_output("PR_release_body",body)
return body

def main():
version_info = releasechecker.get_version_info()
make_release_body(version_info["version"],version_info["quay-image"],version_info["release-info"])
# tarfile = create(args.release)
# print(f'[INFO] Verifier tarball created : {tarfile}.')
# utils.add_output("tarball_full_name",tarfile)

release_body = get_release_body(version_info["version"],version_info["quay-image"],version_info["release-info"])
print(release_body)
3 changes: 2 additions & 1 deletion scripts/src/release/releasechecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def main():
utils.add_output("PR_release_image",version_info["quay-image"])
utils.add_output("PR_release_info",version_info["release-info"])
utils.add_output("PR_includes_release","true")
releasebody.make_release_body(version_info["version"],version_info["quay-image"],version_info["release-info"])
release_body = releasebody.get_release_body(version_info["version"],version_info["quay-image"],version_info["release-info"])
utils.add_output("PR_release_body",release_body)
else:
version_info = get_version_info()
if args.version:
Expand Down

0 comments on commit 95c6b69

Please sign in to comment.