Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

Publish

Publish #54

Workflow file for this run

name: Publish
on:
push:
branches:
# we publish to Test PyPI on pushes to the main branch
- "main"
create:
tags:
- "v*"
env:
PYTHON_VERSION: '3.12'
UV_VERSION: '0.5.6'
permissions:
contents: read
concurrency:
group: publish-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
prepare:
if: github.repository == 'eclipse-csi/octopin'
runs-on: ubuntu-22.04
outputs:
release-tag: ${{ steps.context.outputs.RELEASE_TAG }}
steps:
- name: "Setup context"
id: context
shell: bash
run: |
if [[ "${{ github.ref }}" =~ ^refs/heads/.* ]]; then
echo "RELEASE_TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "RELEASE_TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
build-dist:
runs-on: ubuntu-22.04
needs: ["prepare"]
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
ref: ${{ needs.prepare.outputs.release-tag }}
- name: Setup uv and python
uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0
with:
version: ${{ env.UV_VERSION }}
python-version: ${{ env.PYTHON_VERSION }}
enable-cache: true
cache-dependency-glob: |
pyproject.toml
- name: "Install dependencies"
run: uv sync
- name: "Build package"
run: uv build
- name: "Generate hashes"
id: hash
run: |
cd dist && echo "hashes=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT
- name: "Upload dist"
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: "dist"
path: "dist/"
if-no-files-found: error
retention-days: 5
provenance:
needs: ['prepare', 'build-dist']
permissions:
actions: read
contents: write
id-token: write # Needed to access the workflow's OIDC identity.
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0 # ignore: pin
with:
base64-subjects: "${{ needs.build-dist.outputs.hashes }}"
upload-assets: true
github-publish:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
needs: ['prepare', 'build-dist', 'provenance']
permissions:
contents: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: "Download dists"
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: "dist"
path: "dist/"
- name: "Extract release notes"
id: extract-release-notes
uses: ffurrer2/extract-release-notes@cae32133495112d23e3569ad04fef240ba4e7bc8 # v2.3.0
with:
changelog_file: docs/release-notes.md
release_notes_file: RELEASE_NOTES.md
- name: "Create GitHub release"
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
with:
name: "Octopin ${{ needs.prepare.outputs.release-tag }}"
tag_name: "${{ needs.prepare.outputs.release-tag }}"
body_path: RELEASE_NOTES.md
draft: false
prerelease: false
generate_release_notes: false
make_latest: true
files: dist/*
pypi-publish:
name: "Publish to PyPI"
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
needs: ['build-dist', 'provenance']
environment:
name: pypi
url: https://pypi.org/p/octopin
permissions:
id-token: write
steps:
- name: "Download dists"
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: "dist"
path: "dist/"
- name: "Publish dists to PyPI"
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
attestations: true
verbose: true
test-pypi-publish:
name: "Publish to Test PyPI"
if: startsWith(github.ref, 'refs/heads/')
runs-on: ubuntu-22.04
needs: ['build-dist', 'provenance']
environment:
name: test-pypi
permissions:
id-token: write
steps:
- name: "Download dists"
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: "dist"
path: "dist/"
- name: "Publish dists to Test PyPI"
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
repository-url: https://test.pypi.org/legacy/
attestations: true
verbose: true