name: release on: workflow_run: workflows: [tests] types: [completed] permissions: contents: write concurrency: group: release-${{ github.event.workflow_run.head_sha }} cancel-in-progress: false jobs: publish: if: >- github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' runs-on: ubuntu-latest steps: - name: Check out tested commit uses: actions/checkout@v4 with: persist-credentials: false ref: ${{ github.event.workflow_run.head_sha }} - name: Read package version id: version shell: bash run: | version="$(python -c 'import pathlib, tomllib; print(tomllib.loads(pathlib.Path("pyproject.toml").read_text())["project"]["version"])')" if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$ ]]; then echo "Invalid project version: ${version}" >&2 exit 1 fi echo "version=${version}" >> "${GITHUB_OUTPUT}" echo "tag=v${version}" >> "${GITHUB_OUTPUT}" - name: Build release archive env: VERSION: ${{ steps.version.outputs.version }} shell: bash run: | mkdir -p dist archive="ComfyUI-Image-Conveyor-v${VERSION}.zip" git archive \ --format=zip \ --prefix="ComfyUI-Image-Conveyor-v${VERSION}/" \ --output="dist/${archive}" \ HEAD (cd dist && sha256sum "${archive}" > SHA256SUMS) - name: Publish GitHub release env: GH_TOKEN: ${{ github.token }} RELEASE_SHA: ${{ github.event.workflow_run.head_sha }} TAG: ${{ steps.version.outputs.tag }} VERSION: ${{ steps.version.outputs.version }} shell: bash run: | if gh release view "${TAG}" >/dev/null 2>&1; then echo "Release ${TAG} already exists; leaving it unchanged." exit 0 fi gh release create "${TAG}" \ dist/ComfyUI-Image-Conveyor-v${VERSION}.zip \ dist/SHA256SUMS \ --target "${RELEASE_SHA}" \ --title "Image Conveyor ${TAG}" \ --notes-file RELEASE_NOTES.md