|
| 1 | +name: LBox Alignerr Publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + tag: |
| 7 | + description: 'Release tag (e.g. lbox-alignerr-v0.3.0)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ inputs.tag }} |
| 13 | + cancel-in-progress: false |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + id-token: write |
| 18 | + |
| 19 | +jobs: |
| 20 | + validate-tag: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + version: ${{ steps.version.outputs.version }} |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 26 | + with: |
| 27 | + ref: ${{ inputs.tag }} |
| 28 | + - name: Validate tag and package version |
| 29 | + id: version |
| 30 | + working-directory: libs/lbox-alignerr |
| 31 | + run: | |
| 32 | + set -euo pipefail |
| 33 | + TAG="${{ inputs.tag }}" |
| 34 | + if [[ ! "$TAG" =~ ^lbox-alignerr-v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then |
| 35 | + echo "Tag must match lbox-alignerr-vX.Y.Z, got: $TAG" |
| 36 | + exit 1 |
| 37 | + fi |
| 38 | + EXPECTED_VERSION="${BASH_REMATCH[1]}" |
| 39 | + PACKAGE_VERSION="$(sed -n 's/^version = "\([^"]*\)"/\1/p' pyproject.toml | head -n1)" |
| 40 | + if [[ -z "$PACKAGE_VERSION" ]]; then |
| 41 | + echo "Could not read version from libs/lbox-alignerr/pyproject.toml" |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | + if [[ "$PACKAGE_VERSION" != "$EXPECTED_VERSION" ]]; then |
| 45 | + echo "Tag version $EXPECTED_VERSION does not match pyproject.toml version $PACKAGE_VERSION" |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | + echo "version=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT" |
| 49 | + echo "Publishing lbox-alignerr@$PACKAGE_VERSION from tag $TAG" >> "$GITHUB_STEP_SUMMARY" |
| 50 | +
|
| 51 | + test: |
| 52 | + needs: ['validate-tag'] |
| 53 | + runs-on: ubuntu-latest |
| 54 | + strategy: |
| 55 | + fail-fast: false |
| 56 | + matrix: |
| 57 | + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] |
| 58 | + concurrency: |
| 59 | + # Share with LBox Develop / LBox Publish so staging org tests do not overlap. |
| 60 | + group: lbox-staging-${{ matrix.python-version }}-lbox-alignerr |
| 61 | + cancel-in-progress: false |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 64 | + with: |
| 65 | + ref: ${{ inputs.tag }} |
| 66 | + - uses: ./.github/actions/python-package-shared-setup |
| 67 | + with: |
| 68 | + rye-version: ${{ vars.RYE_VERSION }} |
| 69 | + python-version: ${{ matrix.python-version }} |
| 70 | + - name: Format |
| 71 | + run: rye format --check -v -p lbox-alignerr |
| 72 | + - name: Linting |
| 73 | + run: rye lint -v -p lbox-alignerr |
| 74 | + - name: Unit |
| 75 | + working-directory: libs/lbox-alignerr |
| 76 | + run: rye run unit |
| 77 | + - name: Integration |
| 78 | + working-directory: libs/lbox-alignerr |
| 79 | + env: |
| 80 | + LABELBOX_TEST_API_KEY: ${{ secrets.STAGING_API_KEY_ORG_CMOI3PQ7801GM070D4TPG7FMH }} |
| 81 | + DA_GCP_LABELBOX_API_KEY: ${{ secrets.DA_GCP_LABELBOX_API_KEY }} |
| 82 | + LABELBOX_TEST_ENVIRON: 'staging' |
| 83 | + run: rye run integration |
| 84 | + |
| 85 | + build: |
| 86 | + needs: ['validate-tag', 'test'] |
| 87 | + runs-on: ubuntu-latest |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 90 | + with: |
| 91 | + ref: ${{ inputs.tag }} |
| 92 | + - name: Install the latest version of rye |
| 93 | + uses: eifinger/setup-rye@787604a465b1696ad17eedf2f8101df9fc555c94 # v2 |
| 94 | + with: |
| 95 | + version: ${{ vars.RYE_VERSION }} |
| 96 | + enable-cache: true |
| 97 | + - name: Rye Setup |
| 98 | + run: rye config --set-bool behavior.use-uv=true |
| 99 | + - name: Create build |
| 100 | + working-directory: libs/lbox-alignerr |
| 101 | + run: | |
| 102 | + rye sync |
| 103 | + rye build |
| 104 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 105 | + with: |
| 106 | + name: build-lbox-alignerr |
| 107 | + # rye build in this workspace writes to repo-root dist/ |
| 108 | + path: ./dist |
| 109 | + |
| 110 | + pypi-publish: |
| 111 | + needs: ['validate-tag', 'build', 'test'] |
| 112 | + runs-on: ubuntu-latest |
| 113 | + environment: |
| 114 | + name: publish-lbox-alignerr |
| 115 | + url: 'https://pypi.org/project/lbox-alignerr/' |
| 116 | + permissions: |
| 117 | + # IMPORTANT: this permission is mandatory for trusted publishing |
| 118 | + id-token: write |
| 119 | + steps: |
| 120 | + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 |
| 121 | + with: |
| 122 | + name: build-lbox-alignerr |
| 123 | + path: ./artifact |
| 124 | + - name: Publish package distributions to PyPI |
| 125 | + uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1 |
| 126 | + with: |
| 127 | + packages-dir: artifact/ |
| 128 | + verbose: true |
| 129 | + - name: Summary |
| 130 | + run: | |
| 131 | + echo "Published lbox-alignerr@${{ needs.validate-tag.outputs.version }} to PyPI" >> "$GITHUB_STEP_SUMMARY" |
| 132 | + echo "https://pypi.org/project/lbox-alignerr/${{ needs.validate-tag.outputs.version }}/" >> "$GITHUB_STEP_SUMMARY" |
0 commit comments