Skip to content

Commit 544b32b

Browse files
authored
Improved release workflow (#35)
* further refined package discovery and removed bump2version * fixed more import errors * Created pre-release and tag push workflows * tag pushes now create a release and push to tag * bump version * merged pre-release and tag pushed * Fixed pre-release workflow * another fix for pre-release * fixed pre-merge workflow * fixed pre-release workflow * Fixed pre-release workflow * bumped version * fixed pre-release workflow * removed metadata step from pre-merge and pre-release * bumped version
1 parent 0793697 commit 544b32b

File tree

4 files changed

+104
-20
lines changed

4 files changed

+104
-20
lines changed

.github/workflows/pre-merge.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
pull_request:
55
branches: [ "main" ]
66

7-
env:
8-
IMAGE_NAME: ${{ github.repository }}
97

108
jobs:
119
pre-commit:
@@ -24,11 +22,6 @@ jobs:
2422
steps:
2523
- name: Checkout code
2624
uses: actions/checkout@v2
27-
- name: Extract metadata (tags, labels) for Docker
28-
id: meta
29-
uses: docker/metadata-action@v4
30-
with:
31-
images: ${{ env.IMAGE_NAME }}
3225
- name: Set up Docker Buildx
3326
uses: docker/setup-buildx-action@v2
3427
with:
@@ -38,12 +31,11 @@ jobs:
3831
with:
3932
context: .
4033
target: test
41-
tags: ${{ steps.meta.outputs.tags }}
42-
cache-from: type=gha
34+
tags: unit_test_img:latest
4335
- name: Run tests
4436
run: |
4537
docker run \
4638
-v $PWD:/workspace \
4739
--pull=never \
48-
--rm ${{ steps.meta.outputs.tags }} \
40+
--rm unit_test_img:latest \
4941
pytest

.github/workflows/pre-release.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Create release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
9+
jobs:
10+
validate-tag:
11+
name: Validate tag
12+
runs-on: 'ubuntu-latest'
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
- name: Setup Python
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: '3.9'
22+
- name: Install toml
23+
run: pip install toml
24+
- name: Add version from pyproject.toml to environment vars
25+
run: |
26+
PROJECT_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
27+
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
28+
- name: Check if tag version matches project version
29+
run: |
30+
TAG=$(git describe HEAD --tags --abbrev=0)
31+
echo $TAG
32+
echo $PROJECT_VERSION
33+
if [[ "$TAG" != "v$PROJECT_VERSION" ]]; then exit 1; fi
34+
build-and-test:
35+
name: "Build Docker image and run smoke test"
36+
runs-on: ubuntu-latest
37+
timeout-minutes: 20
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v2
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@v2
43+
with:
44+
driver: docker
45+
- name: Build Docker image
46+
uses: docker/build-push-action@v4
47+
with:
48+
context: .
49+
target: prod
50+
tags: smoke_test_img:latest
51+
- name: Run tests
52+
run: >-
53+
docker run
54+
--pull=never
55+
--rm smoke_test_img:latest
56+
tuned-lens --help
57+
build-n-publish-python-package:
58+
name: Build and publish Python distributions to TestPyPI
59+
runs-on: ubuntu-latest
60+
needs:
61+
- build-and-test
62+
- validate-tag
63+
steps:
64+
- uses: actions/checkout@master
65+
- name: Set up Python 3.10
66+
uses: actions/setup-python@v3
67+
with:
68+
python-version: "3.10"
69+
- name: Install pypa/build
70+
run: >-
71+
python -m
72+
pip install
73+
build
74+
--user
75+
- name: Build a binary wheel and a source tarball
76+
run: >-
77+
python -m
78+
build
79+
--sdist
80+
--wheel
81+
--outdir dist/
82+
.
83+
- name: Publish distribution to Test PyPI
84+
uses: pypa/gh-action-pypi-publish@release/v1
85+
with:
86+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
87+
repository_url: https://test.pypi.org/legacy/
88+
create-draft-release:
89+
name: Create a draft release
90+
runs-on: ubuntu-latest
91+
needs:
92+
- build-and-test
93+
- build-n-publish-python-package
94+
steps:
95+
- name: Create a draft release
96+
uses: softprops/action-gh-release@v1
97+
with:
98+
draft: true

.github/workflows/publish.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
name: Publish to package to PyPI and Docker image to GitHub packages
22

33
on:
4-
push:
5-
tags:
6-
- "v*"
4+
release:
5+
types: [published]
76

87
env:
98
REGISTRY: ghcr.io
@@ -49,7 +48,7 @@ jobs:
4948
cache-to: type=gha,mode=max
5049

5150
build-n-publish-python-package:
52-
name: Build and publish Python distributions to PyPI and TestPyPI
51+
name: Build and publish Python distributions to PyPI
5352
runs-on: ubuntu-latest
5453
steps:
5554
- uses: actions/checkout@master
@@ -71,11 +70,6 @@ jobs:
7170
--wheel
7271
--outdir dist/
7372
.
74-
- name: Publish distribution to Test PyPI
75-
uses: pypa/gh-action-pypi-publish@release/v1
76-
with:
77-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
78-
repository_url: https://test.pypi.org/legacy/
7973
- name: Publish distribution to PyPI
8074
if: startsWith(github.ref, 'refs/tags')
8175
uses: pypa/gh-action-pypi-publish@release/v1

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies = [
2020
"transformers",
2121
"huggingface_hub>=0.12.1",
2222
]
23-
version = "0.0.2"
23+
version = "0.0.3"
2424

2525
[project.optional-dependencies]
2626
dev = [

0 commit comments

Comments
 (0)