-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into package-without-editable-flag
- Loading branch information
Showing
3 changed files
with
129 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Check version increase | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
extract-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Extract package version | ||
id: extract_version | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
python -m pip install packaging | ||
new_version=$(python3 -c "exec(open('./cli/medperf/_version.py').read()); print(__version__)") | ||
echo "version found: [$new_version]" | ||
echo "latest release:" | ||
gh release list --repo ${{ github.repository }} | head -n 1 | ||
latest_version=$(gh release list --repo ${{ github.repository }} | head -n 1 | awk '{print $1}') | ||
echo "latest version found: [$latest_version]" | ||
if [ -z "$latest_version" ]; then | ||
latest_version="0.0.0" | ||
fi | ||
echo "latest version found: [$latest_version]" | ||
python3 -c "from packaging.version import parse; assert parse('$new_version') >= parse('$latest_version'), 'New version must be greater than the latest version'" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: Release Workflow | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
extract-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new_version: ${{ steps.extract_version.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Extract package version | ||
id: extract_version | ||
run: | | ||
version=$(python3 -c "exec(open('./cli/medperf/_version.py').read()); print(__version__)") | ||
echo "version=$version" >> $GITHUB_OUTPUT | ||
echo "version found: [$version]" | ||
check-release: | ||
needs: extract-version | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
outputs: | ||
should_release: ${{ steps.check_release.outputs.should_release }} | ||
steps: | ||
- name: Check if release exists | ||
id: check_release | ||
run: | | ||
version=${{ needs.extract-version.outputs.new_version }} | ||
echo "version found: [$version]" | ||
if gh release view "v$version" --repo ${{ github.repository }}; then | ||
echo "should_release=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "should_release=true" >> $GITHUB_OUTPUT | ||
fi | ||
build-and-sign: | ||
name: Build distribution 📦 | ||
needs: check-release | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
id-token: write | ||
if: needs.check-release.outputs.should_release == 'true' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: python -m pip install --upgrade pip wheel setuptools | ||
- name: Build a binary wheel and a source tarball | ||
run: | | ||
cd cli | ||
python setup.py sdist bdist_wheel | ||
- name: Sign the dists with Sigstore | ||
uses: sigstore/[email protected] | ||
with: | ||
inputs: ./cli/dist/*.tar.gz ./cli/dist/*.whl | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: cli/dist/ | ||
|
||
create-github-release: | ||
name: >- | ||
Sign the Python 🐍 distribution 📦 with Sigstore | ||
and upload them to GitHub Release | ||
needs: [build-and-sign, extract-version] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # Allows for creating releases | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: cli/dist | ||
- name: Create and push tag | ||
run: | | ||
version=${{ needs.extract-version.outputs.new_version }} | ||
echo "version found: [$version]" | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git tag -a "v$version" -m "Release v$version" | ||
git push origin "v$version" | ||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
version=${{ needs.extract-version.outputs.new_version }} | ||
gh release create "v$version" cli/dist/* --generate-notes --repo ${{ github.repository }} |
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