Semantic Release #40
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Semantic Release | |
on: | |
workflow_dispatch: | |
inputs: | |
is_prerelease: | |
description: 'Is this a prerelease?' | |
required: false | |
default: true | |
type: boolean | |
permissions: | |
contents: read | |
jobs: | |
check_release: | |
name: >- | |
πβ - Check if release needed | |
runs-on: ubuntu-latest | |
environment: | |
name: sem-ver | |
concurrency: release | |
# Only run if this is the primary origin main branch | |
if: ${{ github.ref == 'refs/heads/main' && github.repository == 'sandialabs/sansmic' }} | |
outputs: | |
is_prerelease: ${{ steps.semantic_release.outputs.is_prerelease }} | |
released: ${{ steps.semantic_release.outputs.released }} | |
version: ${{ steps.semantic_release.outputs.version }} | |
tag: ${{ steps.semantic_release.outputs.tag }} | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- name: Debug | |
run: | | |
echo "## Inputs" >> $GITHUB_STEP_SUMMARY | |
echo "Is prerelease - " ${{ inputs.is_prerelease }} | tee $GITHUB_STEP_SUMMARY | |
- name: Setup | Checkout Repository at workflow sha | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.sha }} | |
- name: Setup | Force correct release branch on workflow sha | |
run: | | |
git checkout -B ${{ github.ref_name }} ${{ github.sha }} | |
- name: Setup | Get short commit SHA | |
id: vars | |
run: | | |
echo "short_sha=$(git rev-parse --short HEAD)\n" >> $GITHUB_OUTPUT | |
- name: Action | Semantic Release - Update version | |
id: semantic_release | |
# Adjust tag with desired version if applicable. | |
uses: python-semantic-release/python-semantic-release@c1bcfdbb994243ac7cf419365d5894d6bfb2950e # v9.12.0 | |
with: | |
github_token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} | |
git_committer_name: "github-actions" | |
git_committer_email: "[email protected]" | |
build: false | |
changelog: true | |
commit: true | |
push: true | |
tag: false | |
prerelease: ${{ inputs.is_prerelease }} | |
vcs_release: false | |
- name: Action | Output version info | |
run: | | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "## Results of python-semantic-version" >> $GITHUB_STEP_SUMMARY | |
echo "Released " ${{ steps.semantic_release.outputs.released }} >> $GITHUB_STEP_SUMMARY | |
echo "Prerelease " ${{ steps.semantic_release.outputs.is_prerelease }} >> $GITHUB_STEP_SUMMARY | |
echo "Version " ${{ steps.semantic_release.outputs.version }} >> $GITHUB_STEP_SUMMARY | |
echo "Tag " ${{ steps.semantic_release.outputs.tag }} >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
make_sdist: | |
name: >- | |
ποΈππ¦ - Make source distribution package | |
needs: | |
- check_release | |
if: ${{ needs.check_release.outputs.released == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup | Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- name: Setup | Checkout Code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 # Optional, use if you use setuptools_scm | |
submodules: true # Optional, use if you have submodules | |
- name: Action | Build SDist | |
run: pipx run build --sdist | |
- name: Action | Upload Artifacts | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: dist-cibw-sdist | |
path: dist/*.tar.gz | |
build_wheels: | |
name: >- | |
ποΈπ‘π¦ - Build Python wheel for ${{ matrix.os }} | |
needs: | |
- check_release | |
if: ${{ needs.check_release.outputs.released == 'true' }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
# macos-13 is an intel runner, macos-14 is apple silicon | |
os: [ubuntu-latest, windows-latest, macos-13, macos-14] | |
steps: | |
- name: Setup | Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- name: Setup | Checkout Code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Action | Build Wheels | |
uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.0 | |
- name: Action | Upload Artifacts | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: dist-cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
path: ./wheelhouse/*.whl | |
build_win_exe: | |
name: >- | |
ποΈπ₯οΈπ½ - Build standalone executable for Windows | |
needs: | |
- check_release | |
if: ${{ needs.check_release.outputs.released == 'true' }} | |
runs-on: [windows-latest] | |
continue-on-error: true | |
steps: | |
- name: Setup | Install python | |
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 | |
with: | |
python-version: '3.12' | |
- name: Setup | Checkout Code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Setup | Install Dependencies | |
run: | | |
pip install -r requirements.txt -r requirements-exe.txt | |
pip install . | |
python setup.py build_ext -i | |
- name: Setup | Get the sansmic version number | |
id: vars | |
run: | | |
python -c "import sansmic; print('sansmic_version='+sansmic.__version__)" >> $Env:GITHUB_ENV | |
echo "sha_short=$(git rev-parse --short HEAD)" >> $Env:GITHUB_ENV | |
- name: Action | Run PyInstaller | |
run: | | |
pyinstaller --collect-all sansmic --collect-all click --hidden-import sansmic --hidden-import click --hidden-import pandas --hidden-import pybind11 --hidden-import numpy --hidden-import h5py --hidden-import pyyaml --hidden-import lasio -n sansmic --add-binary src/python/sansmic/libsansmic.cp312-win_amd64.pyd:sansmic src/python/sansmic/app.py | |
- name: Action | Create examples | |
run: | | |
mkdir dist/sansmic/examples | |
sansmic-convert tests/baseline.dat dist/sansmic/examples/baseline.toml | |
Compress-Archive -Path dist/sansmic -DestinationPath dist/sansmic-${{ needs.check_release.outputs.version }}-standalone-win_amd64.zip | |
- name: Action | Upload Artifacts | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: dist-exec-windows-latest | |
path: ./dist/sansmic-*-standalone-win_amd64.zip | |
cut_release: | |
name: >- | |
πβοΈ - Create tag and vcs release | |
runs-on: ubuntu-latest | |
needs: | |
- check_release | |
- build_win_exe | |
- make_sdist | |
- build_wheels | |
environment: | |
name: release | |
concurrency: release | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- name: Debug | |
run: | | |
echo "## Inputs" >> $GITHUB_STEP_SUMMARY | |
echo ${{ inputs.releaseType }} | tee $GITHUB_STEP_SUMMARY | |
echo ${{ inputs.force }} | tee $GITHUB_STEP_SUMMARY | |
- name: Setup | Checkout Repository at workflow sha | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.sha }} | |
- name: Setup | Force correct release branch on workflow sha | |
run: | | |
git checkout -B ${{ github.ref_name }} ${{ github.sha }} | |
- name: Setup | Get short commit SHA | |
id: vars | |
run: | | |
echo "short_sha=$(git rev-parse --short HEAD)\n" >> $GITHUB_OUTPUT | |
- name: Setup | Download all the dists | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
pattern: dist-* | |
path: dist | |
merge-multiple: true | |
- name: Action | Sign the dists with Sigstore | |
uses: sigstore/gh-action-sigstore-python@f514d46b907ebcd5bedc05145c03b69c1edd8b46 # v3.0.0 | |
with: | |
inputs: >- | |
./dist/*.zip | |
./dist/*.tar.gz | |
./dist/*.whl | |
- name: Action | Semantic Release - Update version | |
id: semantic_release | |
# Adjust tag with desired version if applicable. | |
uses: python-semantic-release/python-semantic-release@c1bcfdbb994243ac7cf419365d5894d6bfb2950e # v9.12.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
git_committer_name: "github-actions" | |
git_committer_email: "[email protected]" | |
build: false | |
changelog: false | |
commit: false | |
push: true | |
tag: true | |
prerelease: ${{ inputs.is_prerelease }} | |
vcs_release: true | |
- name: Publish | Upload to GitHub Release Assets | |
uses: python-semantic-release/[email protected] | |
if: steps.semVer.outputs.released == 'true' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ steps.semVer.outputs.tag }} | |
- name: Action | Output version info | |
run: | | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "## Results of python-semantic-version" >> $GITHUB_STEP_SUMMARY | |
echo "Released " ${{ steps.semantic_release.outputs.released }} >> $GITHUB_STEP_SUMMARY | |
echo "Prerelease " ${{ steps.semantic_release.outputs.is_prerelease }} >> $GITHUB_STEP_SUMMARY | |
echo "Version " ${{ steps.semantic_release.outputs.version }} >> $GITHUB_STEP_SUMMARY | |
echo "Tag " ${{ steps.semantic_release.outputs.tag }} >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY |