Skip to content

Commit

Permalink
ci: make version reusable
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Peder Meldgaard <[email protected]>
  • Loading branch information
JenspederM committed Dec 28, 2024
1 parent 4b852b3 commit 6ff377a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
DATABRICKS_CLIENT_ID: ${{ secrets.DATABRICKS_CLIENT_ID }}
DATABRICKS_CLIENT_SECRET: ${{ secrets.DATABRICKS_CLIENT_SECRET }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

version:
name: Set Name and Version from pyproject.toml to output
runs-on: ubuntu-latest
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/reusable-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Integration Tests

on:
workflow_call:
inputs:
push:
description: "Push event"
type: boolean
default: false
changelog_path:
description: "Path to the changelog body"
type: string
default: "body.md"
secrets:
GITHUB_TOKEN:
required: true
description: The GitHub token to interact with the GitHub API.
outputs:
name:
value: ${{ jobs.version.outputs.name }}
description: The name of the package.
old_version:
value: ${{ jobs.version.outputs.old_version }}
description: The old version of the package.
new_version:
value: ${{ jobs.version.outputs.new_version }}
description: The new version of the package.

jobs:
version:
name: Set Name and Version from pyproject.toml to output
runs-on: ubuntu-latest
outputs:
name: ${{ steps.project.outputs.NAME }}
old_version: ${{ steps.project.outputs.OLD_VERSION }}
new_version: ${{ steps.cz.outputs.version }}
steps:
- name: Check out
uses: actions/checkout@v4
with:
token: "${{ secrets.GITHUB_TOKEN }}"
fetch-depth: 0
- name: Set Name and Version from pyproject.toml to output
id: project
run: |
name=$(grep "^name" pyproject.toml -m 1 | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3 | tr "-" "_")
version=$(grep "^version" pyproject.toml -m 1 | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
echo "NAME=$name" >> $GITHUB_OUTPUT
echo "OLD_VERSION=$version" >> $GITHUB_OUTPUT
echo "Releasing $name version $version"
- name: Create bump and changelog
id: cz
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
push: ${{ inputs.push }}
changelog_increment_filename: ${{ inputs.changelog_path }}
22 changes: 6 additions & 16 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,9 @@ jobs:
github-token: ${{ github.token }}
title: "Unit Test Coverage Report"
pytest-xml-coverage-path: "coverage.xml"
- name: Set Name and Version from pyproject.toml to output
id: project
run: |
name=$(grep "^name" pyproject.toml -m 1 | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3 | tr "-" "_")
version=$(grep "^version" pyproject.toml -m 1 | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
echo "NAME=$name" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "Releasing $name version $version"
- name: Create bump and changelog
id: cz
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ github.token }}
changelog_increment_filename: body.md
dry_run: true
push: false
version:
name: Set Name and Version from pyproject.toml to output
uses: ./.github/workflows/reuseable-version.yml
secrets:
GITHUB_TOKEN: ${{ github.token }}
push: false

0 comments on commit 6ff377a

Please sign in to comment.