Skip to content

Commit

Permalink
ci(release): Add release Pre-Checks job
Browse files Browse the repository at this point in the history
Do the release pre-checks in its own job instead of the GitHub release publish one.
This allows to completely abort the current release in case one of the artifact fail to build.
  • Loading branch information
gfieni committed Feb 9, 2024
1 parent 7e1c685 commit 61e1724
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,16 @@ permissions:
contents: read

jobs:
github-release:
name: Publish GitHub release
pre-checks:
name: Release Pre-Checks
runs-on: ubuntu-latest
permissions:
contents: write
env:
CHGLOG_VERSION: "0.15.4"
contents: read

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Check PowerAPI package version
- name: Check if package version corresponds to git tag
shell: python
env:
PYTHONPATH: ${{ github.workspace }}/src
Expand All @@ -36,28 +32,15 @@ jobs:
if git_tag != pkg_version:
title = 'Invalid version'
file = 'powerapi/__init__.py'
file = 'src/powerapi/__init__.py'
msg = f'Version mismatch between python package ({pkg_version}) and git tag ({git_tag})'
print(f'::error title={title},file={file}::{msg}')
sys.exit(1)
- name: Generate version changelog
run: |
set -euo pipefail
export BASE_URL="https://github.com/git-chglog/git-chglog/releases/download"
export FILENAME="git-chglog_${CHGLOG_VERSION}_linux_amd64.tar.gz"
curl -fsSL "${BASE_URL}/v${CHGLOG_VERSION}/${FILENAME}" |sudo tar xz --no-same-owner -C /usr/local/bin git-chglog
git-chglog --config .github/chglog/config.yml --output CHANGELOG.md "${GITHUB_REF_NAME}"
- name: Create GitHub release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
body_path: CHANGELOG.md

pypi-package:
name: Publish Pypi package
runs-on: ubuntu-latest
needs: github-release
needs: pre-checks
permissions:
contents: read
id-token: write
Expand Down Expand Up @@ -86,7 +69,7 @@ jobs:
docker-image:
name: Publish Docker image
runs-on: ubuntu-latest
needs: github-release
needs: pre-checks
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -130,3 +113,30 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

github-release:
name: Publish GitHub release
runs-on: ubuntu-latest
needs: [pre-checks, pypi-package, docker-image]
permissions:
contents: write
env:
CHGLOG_VERSION: "0.15.4"

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Generate version changelog
run: |
set -euo pipefail
export BASE_URL="https://github.com/git-chglog/git-chglog/releases/download"
export FILENAME="git-chglog_${CHGLOG_VERSION}_linux_amd64.tar.gz"
curl -fsSL "${BASE_URL}/v${CHGLOG_VERSION}/${FILENAME}" |sudo tar xz --no-same-owner -C /usr/local/bin git-chglog
git-chglog --config .github/chglog/config.yml --output CHANGELOG.md "${GITHUB_REF_NAME}"
- name: Create GitHub release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
body_path: CHANGELOG.md

0 comments on commit 61e1724

Please sign in to comment.