Skip to content

Feature/raw name relax (#56) #142

Feature/raw name relax (#56)

Feature/raw name relax (#56) #142

Workflow file for this run

# Publish package on main branch if it's tagged with 'v*'
name: Release Workflow
# Controls when the action will run.
on:
# Triggers the workflow on push events but only for the master branch
push:
tags:
- 'v*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
UV_HTTP_TIMEOUT: 300
PIP_DISABLE_PIP_VERSION_CHECK: 1
DOCS_PY_VERSION: 3.12
jobs:
check-build:
runs-on: ubuntu-latest
outputs:
build-successful: ${{ steps.check-build-success.outputs.successful }}
run_id: ${{ steps.check-build-success.outputs.run_id }}
steps:
- name: Check latest build status
id: check-build-success
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const tagSha = context.sha;
console.log('current run sha = ' + tagSha)
dev_workflow = 'dev.yml'
const runs = await github.rest.actions.listWorkflowRuns({
owner,
repo,
workflow_id: dev_workflow,
status: 'success',
head_sha: tagSha
});
const successfulRun = runs.data.workflow_runs.find(run => run.head_sha === tagSha);
if (successfulRun) {
core.setOutput('successful', 'true');
core.setOutput('run_id', successfulRun.id);
console.log('Found Successful build run #' + successfulRun.run_number + ', run_id=' + successfulRun.id + ', it was started at ' + successfulRun.created_at)
} else {
core.setOutput('successful', 'false');
core.setFailed('No successful build for this commit/tag');
}
publish:
needs: check-build
if: ${{ needs.check-build.outputs.build-successful == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Get version from tag
id: tag_name
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
shell: bash
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout main repo
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
version: ${{ steps.tag_name.outputs.current_version }}
path: CHANGELOG.md
- uses: actions/setup-python@v5
with:
python-version: ${{ env.DOCS_PY_VERSION }}
- name: Set up rye
run: curl -sSf https://rye.astral.sh/get | RYE_INSTALL_OPTION="--yes" bash
- name: Add Rye to PATH
run: |
echo "$HOME/.rye/env" >> $GITHUB_PATH
echo "$HOME/.rye/shims" >> $GITHUB_PATH
shell: bash
- name: Use uv instead of pip
run: rye config --set-bool behavior.use-uv=true
- name: Verify Rye Installation
run: rye --version
shell: bash
- name: Sync dependencies using rye
run: |
rye pin ${{ env.DOCS_PY_VERSION }}
rye sync --all-features
- name: Setup main repo deploy git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# Build docs but only alias latest for non-dev releases
- name: build documentation
run: |
git fetch origin fusion_release --depth=1
if [[ "${{ steps.tag_name.outputs.current_version }}" != *.dev* ]]; then
# Commands for regular release
rye run mike deploy --branch fusion_release --deploy-prefix docs --push --update-aliases ${{ steps.tag_name.outputs.current_version }} latest
rye run mike set-default --branch fusion_release --deploy-prefix docs --push latest
else
# Commands for pre-release
rye run mike deploy --branch fusion_release --deploy-prefix docs --push ${{ steps.tag_name.outputs.current_version }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v4
with:
pattern: artifacts-*
path: dist/
merge-multiple: true
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
run-id: ${{ needs.check-build.outputs.run_id }}
- name: create github release
id: create_release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog_reader.outputs.changes }}
files: dist/*
draft: ${{ contains(steps.tag_name.outputs.current_version, '.dev') }}
prerelease: ${{ contains(steps.tag_name.outputs.current_version, '.dev') }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: rye run twine upload dist/*