Skip to content

Commit

Permalink
Merge pull request #856 from afuetterer/build-wheel
Browse files Browse the repository at this point in the history
ci: add current git sha to version in build-wheel job
  • Loading branch information
afuetterer authored Dec 5, 2023
2 parents f118f9b + bc88b9a commit 47bdc2c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
40 changes: 31 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ jobs:
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Get short commit SHA
id: short-sha
run: echo "sha=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})" >> $GITHUB_OUTPUT
- name: Get current version (MAJOR.MINOR.PATCH)
id: current-version
run: echo "current_version=$(grep -Po '(?<=__version__ = ")[\d\w.]+(?=")' rdmo/__init__.py)" >> $GITHUB_OUTPUT
- name: Generate new version (current version + SHA)
id: new-version
run: echo "new_version=${{ steps.current-version.outputs.current_version }}+${{ steps.short-sha.outputs.sha }}" >> $GITHUB_OUTPUT
- name: Update version in rdmo/__init__.py
run: |
sed -i "s/__version__ = .*/__version__ = \"${{ steps.new-version.outputs.new_version }}\"/" rdmo/__init__.py
- uses: actions/setup-node@v4
with:
node-version: 18
Expand All @@ -147,17 +159,27 @@ jobs:
with:
python-version: '3.12'
cache: pip
- run: python -m pip install --upgrade build pip setuptools wheel
- run: python -m build --wheel
- run: |
PR_NUMBER=${{ github.event.pull_request.number }}
WHL_FILE=$(ls dist/*.whl)
NEW_NAME="${WHL_FILE/-py3-none-any/dev${PR_NUMBER}-py3-none-any}"
mv "$WHL_FILE" "$NEW_NAME"
- uses: actions/upload-artifact@v3
- run: python -m pip install --upgrade build pip setuptools twine wheel
- name: Build the wheel
run: python -m build --wheel
- name: Check metadata
run: python -m twine check --strict dist/*
- name: Install package from built wheel
run: python -m pip install dist/rdmo*.whl
- name: Write info to step summary
run: |
echo -e "# ✓ Wheel successfully built (v${{ steps.new-version.outputs.new_version }})\n\n" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`console" >> $GITHUB_STEP_SUMMARY
echo "$ python -m pip show rdmo" >> $GITHUB_STEP_SUMMARY
python -m pip show rdmo >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
- name: Upload wheel as artifact
uses: actions/upload-artifact@v3
with:
name: wheel
path: dist/*.whl
path: dist/rdmo*.whl
if-no-files-found: error
retention-days: 30

dev-setup:
# Ref: structlog (MIT licensed) <https://github.com/hynek/structlog/blob/main/.github/workflows/ci.yml>
Expand Down
2 changes: 1 addition & 1 deletion rdmo/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = __version__ = "2.0.2"
__version__ = "2.0.2"

0 comments on commit 47bdc2c

Please sign in to comment.