|
| 1 | +name: Build packages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - 'integration/**' |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + # This section builds the distribution for all versions of Python listed in |
| 12 | + # the python-version matrix under strategy to confirm that it builds for |
| 13 | + # all of those versions. It then uploads the package built by Python 3.9 |
| 14 | + # for use in later jobs. |
| 15 | + name: Build distribution |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + version: ${{ steps.extract_version.outputs.raw_version }} |
| 19 | + rc_version: ${{ steps.extract_release_candidate_version.outputs.version }} |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + python-version: [3.9, 3.10, 3.11, 3.12, 3.13, 3.14] |
| 23 | + steps: |
| 24 | + # Pull the current branch to build the package from. |
| 25 | + - name: Checkout code |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + ref: ${{github.ref}} |
| 29 | + - name: Set up Python |
| 30 | + uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: "3.x" |
| 33 | + - name: Extract version number from __about__.py |
| 34 | + shell: bash |
| 35 | + run: echo "raw_version=`sed -n 's/__version__ = \"\(.*\)\"/\1/p' < sarpy/__about__.py`" >> $GITHUB_OUTPUT |
| 36 | + id: extract_version |
| 37 | + - name: Set version number for release candidate |
| 38 | + shell: bash |
| 39 | + if: contains(github.ref, 'refs/heads/integration/') |
| 40 | + run: | |
| 41 | + echo ${{ steps.extract_version.outputs.raw_version }} |
| 42 | + rc_version=${{ steps.extract_version.outputs.raw_version }}rc0 |
| 43 | + echo "version=$rc_version" >> $GITHUB_OUTPUT |
| 44 | + id: extract_release_candidate_version |
| 45 | + - name: Install pypa/build |
| 46 | + run: >- |
| 47 | + python3 -m |
| 48 | + pip install |
| 49 | + build |
| 50 | + --user |
| 51 | + - name: Build sarpy binary wheel and a source tarball |
| 52 | + run: python3 -m build |
| 53 | + - name: Upload all the dists |
| 54 | + if: matrix.python-version == 3.9 |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: ${{ steps.extract_version.outputs.raw_version }} |
| 58 | + path: dist/ |
| 59 | + overwrite: true |
| 60 | + # This job creates a GitHub release and uploads the package contents created |
| 61 | + # in the build job to the release. |
| 62 | + release: |
| 63 | + name: Create release |
| 64 | + needs: build |
| 65 | + runs-on: ubuntu-latest |
| 66 | + steps: |
| 67 | + - name: Checkout code |
| 68 | + uses: actions/checkout@v4 |
| 69 | + with: |
| 70 | + ref: ${{github.ref}} |
| 71 | + - name: Extract version number from __about__.py |
| 72 | + shell: bash |
| 73 | + run: | |
| 74 | + if "${{endswith(github.ref, 'master')}}" |
| 75 | + then |
| 76 | + echo "version=${{ needs.build.outputs.version }}" >> $GITHUB_OUTPUT |
| 77 | + else |
| 78 | + echo "version=${{ needs.build.outputs.rc_version }}" >> $GITHUB_OUTPUT |
| 79 | + fi |
| 80 | + id: extract_version |
| 81 | + - name: Download all the dists |
| 82 | + uses: actions/download-artifact@v4 |
| 83 | + with: |
| 84 | + name: ${{ needs.build.outputs.version }} |
| 85 | + path: dist |
| 86 | + - name: Create a release |
| 87 | + id: create_release |
| 88 | + uses: softprops/action-gh-release@v2 |
| 89 | + with: |
| 90 | + tag_name: v${{ steps.extract_version.outputs.version }} |
| 91 | + generate_release_notes: true |
| 92 | + name: Version ${{ steps.extract_version.outputs.version }} |
| 93 | + draft: false |
| 94 | + prerelease: false |
| 95 | + target_commitish: ${{github.ref}} |
| 96 | + files: dist/* |
0 commit comments