|
| 1 | +# Copyright 2026 Enactic, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: Package |
| 16 | +on: |
| 17 | + push: |
| 18 | + branches-ignore: |
| 19 | + - 'copilot/**' |
| 20 | + - 'dependabot/**' |
| 21 | + tags: |
| 22 | + - '**' |
| 23 | + pull_request: |
| 24 | +concurrency: |
| 25 | + group: ${{ github.head_ref || github.sha }}-${{ github.workflow }} |
| 26 | + cancel-in-progress: true |
| 27 | +jobs: |
| 28 | + source: |
| 29 | + name: Source |
| 30 | + runs-on: ubuntu-latest |
| 31 | + timeout-minutes: 10 |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v6 |
| 34 | + - name: Prepare environment variables |
| 35 | + run: | |
| 36 | + PACKAGE_NAME=$(yq --unwrapScalar .project.name pyproject.toml) |
| 37 | + echo "PACKAGE_NAME=${PACKAGE_NAME}" >> "${GITHUB_ENV}" |
| 38 | + if [ "${GITHUB_REF_TYPE}" = "tag" ]; then |
| 39 | + echo "VERSION=${GITHUB_REF_NAME}" >> "${GITHUB_ENV}" |
| 40 | + else |
| 41 | + VERSION=$(yq --unwrapScalar .project.version pyproject.toml) |
| 42 | + echo "VERSION=${VERSION}" >> "${GITHUB_ENV}" |
| 43 | + fi |
| 44 | + - uses: actions/setup-python@v6 |
| 45 | + with: |
| 46 | + python-version: 3 |
| 47 | + - name: Install dependencies |
| 48 | + run: | |
| 49 | + pip install build |
| 50 | + - name: Create source archive |
| 51 | + run: | |
| 52 | + python -m build --sdist |
| 53 | + cd dist |
| 54 | + sha256sum \ |
| 55 | + ${PACKAGE_NAME}-${VERSION}.tar.gz > \ |
| 56 | + ${PACKAGE_NAME}-${VERSION}.tar.gz.sha256 |
| 57 | + sha512sum \ |
| 58 | + ${PACKAGE_NAME}-${VERSION}.tar.gz > \ |
| 59 | + ${PACKAGE_NAME}-${VERSION}.tar.gz.sha512 |
| 60 | + - uses: actions/upload-artifact@v7 |
| 61 | + with: |
| 62 | + name: source |
| 63 | + path: | |
| 64 | + dist/${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz |
| 65 | + dist/${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz.sha256 |
| 66 | + dist/${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz.sha512 |
| 67 | + release: |
| 68 | + name: Release |
| 69 | + if: github.ref_type == 'tag' |
| 70 | + needs: |
| 71 | + - source |
| 72 | + runs-on: ubuntu-latest |
| 73 | + timeout-minutes: 10 |
| 74 | + environment: release |
| 75 | + permissions: |
| 76 | + contents: write |
| 77 | + discussions: write |
| 78 | + steps: |
| 79 | + - uses: actions/download-artifact@v8 |
| 80 | + with: |
| 81 | + name: source |
| 82 | + - name: Create GitHub Release |
| 83 | + env: |
| 84 | + GH_TOKEN: ${{ github.token }} |
| 85 | + run: | |
| 86 | + version=${GITHUB_REF_NAME} |
| 87 | + gh release create ${version} \ |
| 88 | + --discussion-category Announcements \ |
| 89 | + --generate-notes \ |
| 90 | + --repo ${GITHUB_REPOSITORY} \ |
| 91 | + --title "OpenArm Driver ${version}" \ |
| 92 | + --verify-tag \ |
| 93 | + *.tar.gz* |
| 94 | + pypi: |
| 95 | + name: PyPI |
| 96 | + if: github.ref_type == 'tag' |
| 97 | + needs: |
| 98 | + - source |
| 99 | + runs-on: ubuntu-latest |
| 100 | + timeout-minutes: 10 |
| 101 | + environment: pypi |
| 102 | + permissions: |
| 103 | + id-token: write |
| 104 | + steps: |
| 105 | + - uses: actions/download-artifact@v8 |
| 106 | + with: |
| 107 | + name: source |
| 108 | + - name: Prepare directory structure |
| 109 | + run: | |
| 110 | + mkdir -p dist |
| 111 | + mv *.tar.gz dist/ |
| 112 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments