Debian Codegraph @

.github/workflows/publish.yml

raw
1 name: Build and Publish Package
2
3 # Publishes two distributions from one release: `harlequin`, and the `hsql`
4 # metapackage in packaging/hsql, which carries the same version number and
5 # pins this release exactly. Both are registered with PyPI's trusted publisher
6 # against this filename and the `publish` environment below; renaming either
7 # one breaks publishing, for both projects.
8
9 on:
10 pull_request:
11 branches:
12 - main
13 types:
14 - closed
15
16 jobs:
17 publish-package:
18 if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v') }}
19 runs-on: ubuntu-latest
20 environment: publish
21 permissions:
22 id-token: write
23
24 steps:
25 - name: Check out harlequin main branch
26 uses: actions/checkout@v7
27 with:
28 ref: main
29
30 - name: Set up Python 3.10
31 uses: actions/setup-python@v7
32 with:
33 python-version: "3.10"
34
35 - name: Install uv
36 uses: astral-sh/[email protected]
37 with:
38 version: "0.12.8"
39
40 - name: Get harlequin Version
41 id: harlequin_version
42 run: echo "harlequin_version=$(uv version --short)" >> $GITHUB_OUTPUT
43
44 - name: Build package
45 run: uv build --all-packages
46
47 - name: Build hsql metapackage
48 run: uv build packaging/hsql --out-dir dist
49
50 - name: Check that hsql pins this release
51 run: |
52 version="${{ steps.harlequin_version.outputs.harlequin_version }}"
53 if [ ! -f "dist/hsql-$version.tar.gz" ]; then
54 echo "::error::dist/ has no hsql-$version; hsql is out of step with harlequin."
55 ls -la dist/
56 exit 1
57 fi
58
59 - name: Publish packages to PyPI
60 uses: pypa/gh-action-pypi-publish@release/v1
61
62 - name: Create a Github Release
63 uses: softprops/action-gh-release@v3
64 with:
65 tag_name: v${{ steps.harlequin_version.outputs.harlequin_version }}
66 target_commitish: main
67 token: ${{ secrets.HARLEQUIN_RELEASE_TOKEN }}
68 body_path: CHANGELOG.md
69 files: |
70 LICENSE
71 dist/*harlequin*.whl
72 dist/*harlequin*.tar.gz
73 dist/*hsql*.whl
74 dist/*hsql*.tar.gz
75
76 # the site vendors this release's generated artifacts -- the config schema,
77 # the CLI reference and the skill -- so it publishes after PyPI does, when
78 # the version the manifest names is one a reader can install.
79 publish-artifacts:
80 needs: publish-package
81 uses: ./.github/workflows/publish-artifacts.yml
82 secrets: inherit