Skip to content

Commit 8506985

Browse files
jiripetrlikanishasthana
authored andcommitted
Create GitHub action to automate release
1 parent ac02248 commit 8506985

File tree

5 files changed

+92
-47
lines changed

5 files changed

+92
-47
lines changed

.github/workflows/image.yml

-37
This file was deleted.

.github/workflows/release.yaml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release-version:
7+
type: string
8+
required: true
9+
description: 'Version number (for example: 0.1.0)'
10+
is-latest:
11+
description: 'Select if the built image should be tagged as latest'
12+
required: true
13+
type: boolean
14+
quay-organization:
15+
description: 'Quay organization used to push the built images to'
16+
required: true
17+
default: 'project-codeflare'
18+
python_version:
19+
type: string
20+
default: "3.8"
21+
required: true
22+
poetry_version:
23+
type: string
24+
default: "1.5.1"
25+
required: true
26+
27+
jobs:
28+
release:
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: write
32+
steps:
33+
- name: Checkout the repository
34+
uses: actions/checkout@v3
35+
- name: Install Python
36+
uses: actions/setup-python@v4
37+
with:
38+
python-version: ${{ github.event.inputs.python_version }}
39+
- name: Install Poetry
40+
uses: abatilo/actions-poetry@v2
41+
with:
42+
poetry-version: ${{ github.event.inputs.poetry_version }}
43+
- name: Change version in pyproject.toml
44+
run: poetry version "${{ github.event.inputs.release-version }}"
45+
- name: Run poetry install
46+
run: poetry install --with docs
47+
- name: Run poetry build
48+
run: poetry build
49+
- name: Create new documentation
50+
run: poetry run pdoc --html -o docs src/codeflare_sdk && pushd docs && rm -rf cluster job utils && mv codeflare_sdk/* . && rm -rf codeflare_sdk && popd
51+
- name: Set Pypi token
52+
run: poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
53+
- name: Publish new release to Pypi repository
54+
run: poetry publish
55+
56+
- name: Commit changes in docs
57+
uses: stefanzweifel/git-auto-commit-action@v4
58+
with:
59+
file_pattern: 'docs'
60+
commit_message: "Changes in docs for release: v${{ github.event.inputs.release-version }}"
61+
- name: Create Github release
62+
uses: ncipollo/release-action@v1
63+
with:
64+
tag: "v${{ github.event.inputs.release-version }}"
65+
66+
- name: Image Build
67+
run: |
68+
cd custom-nb-image
69+
docker build --build-arg SDK_VERSION="${{ github.event.inputs.release-version }}" -t quay.io/${{ github.event.inputs.quay-organization }}/notebook:v${{ github.event.inputs.release-version }} .
70+
docker tag quay.io/${{ github.event.inputs.quay-organization }}/notebook:v${{ github.event.inputs.release-version }} quay.io/${{ github.event.inputs.quay-organization }}/notebook:latest
71+
- name: Login to Quay.io
72+
uses: docker/login-action@v2
73+
with:
74+
registry: quay.io
75+
username: ${{ secrets.QUAY_ID }}
76+
password: ${{ secrets.QUAY_TOKEN }}
77+
- name: Image Push
78+
run: docker push quay.io/${{ github.event.inputs.quay-organization }}/notebook:v${{ github.event.inputs.release-version }}
79+
- name: Image Push Latest
80+
if: ${{ inputs.is-latest }}
81+
run: docker push quay.io/${{ github.event.inputs.quay-organization }}/notebook:latest

README.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ To build the python package: `$ poetry build`
5151

5252
## Release Instructions
5353

54-
The following instructions apply when doing release manually.
54+
55+
### Automated Releases
56+
57+
It is possible to use the Release Github workflow to do the release. This is generally the process we follow for releases
58+
59+
### Manual Releases
60+
61+
The following instructions apply when doing release manually. This may be required in instances where the automation is failing.
5562

5663
* Check and update the version in "pyproject.toml" file.
5764
* Generate new documentation.
@@ -62,14 +69,9 @@ The following instructions apply when doing release manually.
6269
* If not present already, add the API token to Poetry.
6370
`poetry config pypi-token.pypi API_TOKEN`
6471
* Publish the Python package. `poetry publish`
65-
* Check and update the version in "custom-nb-image/VERSION" file.
66-
* Update the codeflare-sdk version in "custom-nb-image/Dockerfile".
67-
* Commit all the changes to the repository.
68-
* The Github "Image" workflow should take care about the building and publishing of the new image. If not you can
69-
use the following instructions to build and publish image manually.
7072
* Change directory to custom-nb-image. `cd custom-nb-image`
71-
* Get tag `export tag=$(cat VERSION)`
72-
* Build the Docker image. `docker build -t quay.io/project-codeflare/notebook:${tag} .`
73+
* Set tag `export tag=TAG`
74+
* Build the Docker image. `docker build --build-arg SDK_VERSION=<version> -t quay.io/project-codeflare/notebook:${tag} .`
7375
* Tag the image as latest. `docker tag quay.io/project-codeflare/notebook:${tag} quay.io/project-codeflare/notebook:latest`
7476
* Login to quay.io. `docker login quay.io`
7577
* Push the image. `docker push quay.io/project-codeflare/notebook:${tag}`

custom-nb-image/VERSION

-1
This file was deleted.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "codeflare-sdk"
3-
version = "0.4.5"
3+
version = "0.0.0-dev"
44
description = "Python SDK for codeflare client"
55

66
license = "Apache-2.0"

0 commit comments

Comments
 (0)