Add python publish to release.yml #7
Workflow file for this run
This file contains hidden or 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: Python Poetry Release and Publish | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
permissions: | |
contents: write | |
env: | |
PYPI_USERNAME: __token__ | |
PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
jobs: | |
release-and-publish: | |
runs-on: ubuntu-latest | |
env: | |
JAVA_HOME: ${{ github.workspace }}/graalvm-ce-java11-22.3.3 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Set up JDK 11 from GraalVM | |
run: | | |
echo "${{ env.JAVA_HOME }}/bin" >> $GITHUB_PATH | |
wget https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.3/graalvm-ce-java11-linux-amd64-22.3.3.tar.gz | |
tar -xvzf graalvm-ce-java11-linux-amd64-22.3.3.tar.gz | |
${{ env.JAVA_HOME }}/bin/gu install native-image | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
echo "${HOME}/.local/bin" >> $GITHUB_PATH | |
- name: Configure Poetry | |
run: | | |
poetry config virtualenvs.in-project true | |
poetry config virtualenvs.create false | |
- name: Install Dependencies | |
run: poetry install --sync --no-interaction | |
- name: Run Tests | |
id: build | |
continue-on-error: true # Allow workflow continuation on failure | |
run: poetry run make test | |
- name: Delete tag on failure | |
if: steps.build.outcome != 'success' | |
run: | | |
git push --delete origin ${GITHUB_REF#refs/tags/} | |
exit 1 # Fail the workflow | |
- name: Inject the latest Code Analyzer JAR | |
run: | | |
CODE_ANALYZER_URL=$(curl -s https://api.github.com/repos/IBM/codenet-minerva-code-analyzer/releases/latest | jq -r '.assets[] | .browser_download_url') | |
echo "Downloading: " $CODE_ANALYZER_URL | |
wget -q $CODE_ANALYZER_URL | |
echo "Moving codeanalyzer jar to:" ${{ github.workspace }}/cldk/analysis/java/codeanalyzer/jar/ | |
mv codeanalyzer-*.jar ${{ github.workspace }}/cldk/analysis/java/codeanalyzer/jar/ | |
- name: Build Package | |
run: poetry build | |
- name: Build Changelog | |
id: gen_changelog | |
uses: mikepenz/release-changelog-builder-action@v5 | |
with: | |
failOnError: "true" | |
configuration: .github/workflows/release_config.json | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish Release on GitHub | |
id: github_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: dist/* | |
body: ${{ steps.gen_changelog.outputs.changelog }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish package distributions to PyPI | |
run: poetry publish --username $PYPI_USERNAME --password $PYPI_PASSWORD |