Skip to content

chore: add SLSA badge #13

chore: add SLSA badge

chore: add SLSA badge #13

Workflow file for this run

name: Publish
on:
push:
branches:
# we publish to Test PyPI on pushes to the main branch
- "main"
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@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
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.0.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@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: "dist"
path: "dist/"
- name: "Extract release notes"
id: extract-release-notes
uses: ffurrer2/extract-release-notes@9989ccec43d726ef05aa1cd7b2854fb96b6df6ab # v2.2.0
with:
changelog_file: docs/release-notes.md
release_notes_file: RELEASE_NOTES.md
- name: "Create GitHub release"
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0
with:
name: "Otterdog ${{ 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@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: "dist"
path: "dist/"
- name: "Publish dists to PyPI"
uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2
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@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: "dist"
path: "dist/"
- name: "Publish dists to Test PyPI"
uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2
with:
repository-url: https://test.pypi.org/legacy/
attestations: true
verbose: true