Skip to content

Commit

Permalink
Trigger pip release on github release publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
m-dzianishchyts committed Oct 3, 2024
1 parent 573c87d commit b772f42
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 81 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: 'prepare release'

on:
push:
tags:
- '[0-9]+.[0-9]+.?[ab]?[0-9]+'
permissions:
# allow a write access to GitHub Releases
contents: write

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'

- name: Install build dependencies
run: pip install build

- name: Build
env:
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_jjava: ${{ github.ref_name }}
run: |
mvn clean verify -U
python -m build
- name: Collect the release distributions
run: |
mkdir -p release/
cp jjava/target/jjava-${{ github.ref_name }}-kernelspec.tar.gz release/
cp -r dist/* release/
- name: Store the release distributions
uses: actions/upload-artifact@v4
with:
name: release-distributions
path: release/
if-no-files-found: error

prepare-release:
runs-on: ubuntu-latest
needs:
- build

steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: release-distributions
path: release/

- name: Create release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
body: JJava ${{ github.ref_name }} release
draft: true
prerelease: false
files: release/*
fail_on_unmatched_files: true
91 changes: 10 additions & 81 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,98 +1,27 @@
name: 'create release'
name: 'release packages'

on:
push:
tags:
- '[0-9]+.[0-9]+.?[ab]?[0-9]+'
permissions:
# allow a write access to GitHub Releases
contents: write
release:
types: [published]

jobs:
build:
release-pypi:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'

- name: Install build dependencies
run: pip install build

- name: Build
env:
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_jjava: ${{ github.ref_name }}
run: |
mvn clean verify -U
python -m build
- name: Store the release distribution archive
uses: actions/upload-artifact@v4
with:
name: release-distributions
path: jjava/target/jjava-${{ github.ref_name }}.zip
if-no-files-found: error

- name: Store the python distribution packages
uses: actions/upload-artifact@v4
with:
name: python-distributions
path: dist/
if-no-files-found: error

prepare-release:
runs-on: ubuntu-latest
needs:
- build

steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: release-distributions
path: release/

- name: Create release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
body: JJava ${{ github.ref_name }} release
draft: true
prerelease: false
files: release/*
fail_on_unmatched_files: true

deploy-pypi:
runs-on: ubuntu-latest
needs:
- build
environment:
name: pypi
url: https://pypi.org/p/jjava
permissions:
id-token: write

steps:
- name: Download distributions
uses: actions/download-artifact@v4
- name: Download release assets
uses: robinraju/release-downloader@v1
with:
name: python-distributions
path: dist/
tag: ${{ github.ref_name }}
fileName: jjava-!(kernelspec)*@(.tar.gz|.whl)
out-file-path: dist/

- name: Deploy distributions to PyPI
- name: Publish distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
Expand Down

0 comments on commit b772f42

Please sign in to comment.