Skip to content

LabSDK - Release and publish a version #53

LabSDK - Release and publish a version

LabSDK - Release and publish a version #53

name: LabSDK - Release and publish a version
on:
workflow_dispatch:
inputs:
prerelease:
default: true
description: Is this a pre-release version?
required: true
type: boolean
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.changelog.outputs.version }}
tag: ${{ steps.changelog.outputs.tag }}
changelog: ${{ steps.changelog.outputs.changelog }}
clean_changelog: ${{ steps.changelog.outputs.clean_changelog }}
skipped: ${{ steps.changelog.outputs.skipped }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Conventional Changelog Action
id: changelog
uses: TriPSs/conventional-changelog-action@v5
with:
release-count: '1'
skip-version-file: 'true'
skip-commit: 'true'
skip-git-pull: 'true'
git-push: 'false'
git-path: 'labsdk'
tag-prefix: 'LabSDK-v'
fallback-version: '0.3.1'
build_dist:
needs: [ version ]
name: Build distributions - source and wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Override the version for the dist code
working-directory: ./labsdk/
run: |
sed -i "s/^version *= *.*/version = '${{ needs.version.outputs.version }}'/" setup.py
- name: Make changelog for the dist code
working-directory: ./labsdk/
run: |
echo "${{ needs.version.outputs.changelog }}" > CHANGELOG.md
- name: Build SDist
working-directory: ./labsdk/
env:
BUILD_VERSION: "${{ needs.version.outputs.version }}"
run: pipx run build --sdist --wheel
- uses: actions/upload-artifact@v4
with:
path: |
./labsdk/dist/*.tar.gz
./labsdk/dist/*.whl
release:
name: "Release and publish the version"
needs: [ version, build_dist ]
runs-on: ubuntu-latest
steps:
- name: "Fetch the artifacts"
uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- name: "Publish to PyPi"
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.BOT_PAT }}
- name: Update changelog
shell: bash
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
touch labsdk/CHANGELOG.md
echo -e "${{ needs.version.outputs.changelog }}\n\n$(cat labsdk/CHANGELOG.md)" > labsdk/CHANGELOG.md
git add labsdk/CHANGELOG.md
git commit -m "chore(LabSDK-release): ${{ needs.version.outputs.version }}" labsdk/CHANGELOG.md
git push
- name: Tag
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ needs.version.outputs.tag }}',
sha: context.sha
})
- name: Release on GitHub
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.version.outputs.tag }}
files: dist/*
body: |
Released to https://pypi.org/project/raptor-labsdk/${{ needs.version.outputs.version }}/
---
${{ needs.version.outputs.clean_changelog }}
prerelease: ${{ inputs.prerelease }}
name: LabSDK - Version ${{ needs.version.outputs.version }}
generate_release_notes: false