Skip to content

Publish Release

Publish Release #2

name: Publish Release
on:
push:
branches:
- release_bfabric
- release_bfabric_scripts
- release_app_runner
workflow_dispatch:
inputs:
package:
description: 'Package to release'
type: choice
options:
- bfabric
- bfabric_scripts
- app_runner
default: bfabric
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Step: Determine the package that is being built.
- name: Set package variable
id: set-package
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "PACKAGE=${{ github.event.inputs.package }}" >> $GITHUB_ENV
else
# Extract package name from branch name by removing 'release_' prefix
BRANCH_NAME="${{ github.ref_name }}"
PACKAGE=${BRANCH_NAME#release_}
echo "PACKAGE=$PACKAGE" >> $GITHUB_ENV
fi
- name: Debug package variable
run: echo "Selected package is ${{ env.PACKAGE }}"
# Step: Build the package
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install hatch
run: pip install hatch twine
- name: Build package
run: |
cd ${{ env.PACKAGE }}
hatch build
- name: Publish to TestPyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
run: |
cd ${{ env.PACKAGE }}
twine upload --skip-existing dist/*
- name: Debug package info
run: |
echo "Built and published package: ${{ env.PACKAGE }}"
echo "Check it at: https://test.pypi.org/project/${{ env.PACKAGE }}/"