|
| 1 | +# Copyright 2024 Google LLC |
| 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 | + |
| 16 | +# This workflow will create a release with git tag and publish a Python Package in PyPI. |
| 17 | +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions; https://docs.pypi.org/trusted-publishers/adding-a-publisher/ |
| 18 | + |
| 19 | +name: Create Release |
| 20 | + |
| 21 | +on: |
| 22 | + push: |
| 23 | + tags: |
| 24 | + - v* |
| 25 | + |
| 26 | +# Needed to create release and upload assets |
| 27 | +permissions: |
| 28 | + contents: write |
| 29 | + |
| 30 | +jobs: |
| 31 | + release: |
| 32 | + name: Create Release with tag |
| 33 | + runs-on: ${{ matrix.os }} |
| 34 | + needs: release |
| 35 | + strategy: |
| 36 | + matrix: |
| 37 | + os: [ubuntu-20.04] |
| 38 | + python-version: ['3.10'] |
| 39 | + steps: |
| 40 | + - name: Checkout |
| 41 | + uses: actions/checkout@v4 |
| 42 | + - name: Extract release tag from branch |
| 43 | + shell: bash |
| 44 | + run: | |
| 45 | + echo "release_tag=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 46 | + - name: Create Github Release |
| 47 | + id: create_release |
| 48 | + uses: "actions/github-script@v6" |
| 49 | + env: |
| 50 | + RELEASE_TAG: ${{ env.release_tag }} |
| 51 | + with: |
| 52 | + github-token: "${{ secrets.GITHUB_TOKEN }}" |
| 53 | + script: | |
| 54 | + const script = require('.github/workflows/scripts/create_release.js') |
| 55 | + await script(github, context, core) |
| 56 | +
|
| 57 | + pypi: |
| 58 | + name: Build and Publish JetStream Python Package |
| 59 | + runs-on: ${{ matrix.os }} |
| 60 | + needs: release |
| 61 | + strategy: |
| 62 | + matrix: |
| 63 | + os: [ubuntu-20.04] |
| 64 | + python-version: ['3.10'] |
| 65 | + environment: |
| 66 | + name: pypi |
| 67 | + url: https://pypi.org/project/google-jetstream |
| 68 | + permissions: |
| 69 | + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
| 70 | + steps: |
| 71 | + - name: Checkout |
| 72 | + uses: actions/checkout@v4 |
| 73 | + - name: Setup Python |
| 74 | + uses: actions/setup-python@v4 |
| 75 | + with: |
| 76 | + python-version: ${{ matrix.python-version }} |
| 77 | + - name: Build Python distribution package |
| 78 | + run: | |
| 79 | + python -m pip install --upgrade build && python -m build |
| 80 | + - name: Publish Python package to PyPI |
| 81 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments