Skip to content

Commit 164195b

Browse files
authored
Merge pull request #24 from b-long/develop
Version 0.1.12, DRY CI build and PyPI Trusted Publisher 🚀
2 parents 668bf1c + ccdb591 commit 164195b

File tree

11 files changed

+162
-215
lines changed

11 files changed

+162
-215
lines changed
Lines changed: 32 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
---
2-
name: macOS -- Build Python wheel using golang's gopy
2+
name: macOS build
33

4-
on:
5-
push:
6-
branches:
7-
- main
4+
on: [push]
85

96
defaults:
107
run:
@@ -17,102 +14,37 @@ jobs:
1714
build:
1815
runs-on: macos-13
1916
permissions:
20-
contents: write
17+
contents: write
2118

2219
strategy:
23-
fail-fast: true
24-
matrix:
25-
go-version: [1.22.x]
20+
fail-fast: true
21+
matrix:
22+
go-version: [1.22.x]
23+
python3_version: [ "3.11", "3.12" ]
2624

2725
steps:
28-
- uses: actions/checkout@v4
29-
30-
# - name: Setup Docker on macOS using Colima, Lima-VM, and Homebrew
31-
# uses: douglascamata/setup-docker-macos-action@v1-alpha
32-
33-
34-
# - name: Verify docker Installation
35-
# run: |
36-
# docker --version
37-
# docker ps
38-
39-
# - name: Setup vagrant
40-
# run: |
41-
# brew install vagrant
42-
# vagrant --version
43-
44-
- name: Setup Go
45-
uses: actions/setup-go@v4
46-
with:
47-
go-version: ${{ matrix.go-version }}
48-
cache-dependency-path: go.sum
49-
- name: Install dependencies
50-
run: go get .
51-
- name: Test with Go
52-
run: go test -timeout 40s -run ^TestHello$ gotdf_python -count=1 # go test
53-
54-
- name: Set up Python
55-
uses: actions/setup-python@v4
56-
with:
57-
python-version: '3.12'
58-
59-
- name: Install dependencies
60-
run: |
61-
pip install poetry
62-
63-
# Look for go/bin (skip, we know it exists)
64-
echo '$HOME/'
65-
ls -la "$HOME/"
66-
67-
echo '$HOME/.local/'
68-
ls -la "$HOME/.local/"
69-
70-
echo '$HOME/go/'
71-
ls -la "$HOME/go/"
72-
73-
- name: Add Go bin directory to PATH
74-
run: echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV
75-
76-
# FIXME: Add more caching
77-
- name: Add gopy dependencies and build wheel
78-
run: |
79-
./ci-build.sh
80-
81-
- name: Test Python wheel
82-
run: |
83-
# Test wheel installation
84-
pip install dist/otdf_python-0.1.10-py3-none-any.whl
85-
86-
# Test wheel functionality
87-
# python3 validate_otdf_python.py
88-
89-
# - uses: ./.github/workflows/platform-integration-test.yaml
90-
# with:
91-
# wheel: dist/otdf_python-0.1.10-py3-none-any.whl
92-
93-
# release:
94-
# needs: build
95-
# runs-on: macos-latest
96-
# if: github.ref == 'refs/heads/main'
97-
# permissions:
98-
# contents: write
99-
# steps:
100-
# - uses: actions/checkout@v4
101-
102-
- name: Store version
103-
run: |
104-
pip install poetry
105-
106-
PROJECT_VESION=$(poetry version -s)
107-
echo "PROJECT_VESION=$PROJECT_VESION" >> $GITHUB_ENV
108-
109-
- name: Install twine
110-
run: pip install twine
111-
112-
- name: Upload to PyPI
113-
env:
114-
TWINE_UPLOAD_URL: https://upload.pypi.org/legacy/
115-
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
116-
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
117-
run: |
118-
twine upload --password "$PYPI_PASSWORD" --user "$PYPI_USERNAME" --repository-url "$TWINE_UPLOAD_URL" dist/*
26+
- uses: actions/checkout@v4
27+
28+
- name: Setup Go
29+
uses: actions/setup-go@v4
30+
with:
31+
go-version: ${{ matrix.go-version }}
32+
cache-dependency-path: go.sum
33+
- name: Install dependencies
34+
run: go get .
35+
- name: Test with Go
36+
run: go test -timeout 40s -run ^TestHello$ gotdf_python -count=1 # go test
37+
38+
- name: Set up Python
39+
uses: actions/setup-python@v4
40+
with:
41+
python-version: ${{ matrix.python3_version }}
42+
43+
# FIXME: Add more caching
44+
- name: Configure gopy / dependencies, and build wheel
45+
run: |
46+
./ci-build.sh
47+
48+
# - uses: ./.github/workflows/platform-integration-test.yaml
49+
# with:
50+
# wheel: dist/otdf_python-0.1.12-py3-none-any.whl
Lines changed: 60 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,65 @@
11
---
2-
name: Ubuntu -- Build Python wheel using golang's gopy
2+
name: Ubuntu build
33

44
on: [push]
55

66
jobs:
7-
call-lint:
8-
uses: ./.github/workflows/lint-on-ubuntu.yaml
9-
10-
build:
11-
runs-on: ubuntu-latest
12-
permissions:
13-
contents: write
14-
15-
strategy:
16-
fail-fast: true
17-
matrix:
18-
go-version: [1.22.x]
19-
# go-version: [ '1.19', '1.20', '1.22.x' ]
20-
21-
steps:
22-
- uses: actions/checkout@v4
23-
24-
25-
- name: Setup Go
26-
uses: actions/setup-go@v4
27-
with:
28-
go-version: ${{ matrix.go-version }}
29-
cache-dependency-path: go.sum
30-
- name: Install dependencies
31-
run: go get .
32-
- name: Test with Go
33-
run: go test -timeout 40s -run ^TestHello$ gotdf_python -count=1 # go test
34-
35-
- name: Set up Python
36-
uses: actions/setup-python@v4
37-
with:
38-
python-version: '3.12'
39-
40-
- name: Install dependencies
41-
run: |
42-
pip install poetry
43-
44-
# Look for go/bin (skip, we know it exists)
45-
echo '$HOME/'
46-
ls -la "$HOME/"
47-
48-
echo '$HOME/.local/'
49-
ls -la "$HOME/.local/"
50-
51-
echo '$HOME/go/'
52-
ls -la "$HOME/go/"
53-
54-
- name: Add Go bin directory to PATH
55-
run: echo "export PATH=$PATH:~/.local/go/bin" >> $GITHUB_ENV
56-
57-
# FIXME: Add more caching
58-
- name: Add gopy dependencies and build wheel
59-
run: |
60-
./ci-build.sh
61-
62-
- name: Check existing workspace content
63-
run: |
64-
ls -la
65-
ls -la dist/
66-
67-
- name: Test Python wheel
68-
run: |
69-
# Test wheel installation
70-
pip install dist/otdf_python-0.1.10-py3-none-any.whl
71-
72-
# DISABLED: Need to figure out Ubuntu nested VM
73-
# Test wheel functionality
74-
# python3 validate_otdf_python.py
75-
76-
- uses: actions/cache/restore@v4
77-
with:
78-
path: dist/otdf_python-0.1.10-py3-none-any.whl
79-
key: ${{ runner.os }}-data-${{ github.sha }}
80-
81-
- uses: actions/cache/save@v4
82-
with:
83-
path: dist/otdf_python-0.1.10-py3-none-any.whl
84-
key: ${{ runner.os }}-data-${{ github.sha }}
85-
restore-keys: |
86-
${{ runner.os }}-data-
87-
88-
integration-test:
89-
needs: build
90-
uses: ./.github/workflows/platform-integration-test.yaml
91-
with:
92-
wheel: dist/otdf_python-0.1.10-py3-none-any.whl
7+
call-lint:
8+
uses: ./.github/workflows/lint-on-ubuntu.yaml
9+
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
strategy:
16+
fail-fast: true
17+
matrix:
18+
go-version: [1.22.x]
19+
python3_version: [ "3.11", "3.12" ]
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Setup Go
25+
uses: actions/setup-go@v4
26+
with:
27+
go-version: ${{ matrix.go-version }}
28+
cache-dependency-path: go.sum
29+
- name: Install dependencies
30+
run: go get .
31+
- name: Test with Go
32+
run: go test -timeout 40s -run ^TestHello$ gotdf_python -count=1 # go test
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@v4
36+
with:
37+
python-version: ${{ matrix.python3_version }}
38+
39+
# FIXME: Add more caching
40+
- name: Configure gopy / dependencies, and build wheel
41+
run: |
42+
./ci-build.sh
43+
44+
- uses: actions/cache/restore@v4
45+
with:
46+
path: dist/otdf_python-0.1.12-py3-none-any.whl
47+
key: ${{ runner.os }}${{ matrix.python3_version }}-data-${{ github.sha }}
48+
49+
- uses: actions/cache/save@v4
50+
with:
51+
path: dist/otdf_python-0.1.12-py3-none-any.whl
52+
key: ${{ runner.os }}${{ matrix.python3_version }}-data-${{ github.sha }}
53+
restore-keys: |
54+
${{ runner.os }}${{ matrix.python3_version }}-data-
55+
56+
integration-test:
57+
strategy:
58+
fail-fast: true
59+
matrix:
60+
python3_version: [ "3.11", "3.12" ]
61+
needs: build
62+
uses: ./.github/workflows/platform-integration-test.yaml
63+
with:
64+
wheel: dist/otdf_python-0.1.12-py3-none-any.whl
65+
python_version: ${{ matrix.python3_version }}

.github/workflows/platform-integration-test.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
description: The Python wheel to test
1313
required: true
1414
type: string
15+
python_version:
16+
description: The wheel's Python version (like "3.12" or "3.13")
17+
required: true
18+
type: string
1519

1620
permissions:
1721
contents: read
@@ -25,8 +29,8 @@ jobs:
2529

2630
- uses: actions/cache/restore@v4
2731
with:
28-
path: dist/otdf_python-0.1.10-py3-none-any.whl
29-
key: ${{ runner.os }}-data-${{ github.sha }}
32+
path: dist/otdf_python-0.1.12-py3-none-any.whl
33+
key: ${{ runner.os }}${{ inputs.python_version }}-data-${{ github.sha }}
3034

3135
- name: Prove that the input file is available
3236
shell: bash
@@ -112,7 +116,7 @@ jobs:
112116
- name: Set up Python
113117
uses: actions/setup-python@v4
114118
with:
115-
python-version: '3.12'
119+
python-version: ${{ inputs.python_version }}
116120

117121
- name: Validate the Python SDK
118122
env:

.github/workflows/publish-test.yaml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ jobs:
180180
release:
181181
permissions:
182182
contents: write
183+
# This permission is mandatory for PyPI's trusted publishing
184+
id-token: write
183185
needs: [build_macos, build_linux_x86_64]
184186
runs-on: ubuntu-latest
185187
# if: github.ref == 'refs/heads/main'
@@ -202,22 +204,23 @@ jobs:
202204
PROJECT_VESION=$(poetry version -s)
203205
echo "PROJECT_VESION=$PROJECT_VESION" >> $GITHUB_ENV
204206
205-
- name: Install twine
206-
run: pip install twine
207-
208-
- name: Upload to PyPI
209-
env:
210-
TWINE_UPLOAD_URL: https://test.pypi.org/legacy/
211-
PYPI_USERNAME: ${{ secrets.PYPI_TEST_USERNAME }}
212-
PYPI_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }}
213-
run: |
214-
twine upload --password "$PYPI_PASSWORD" --user "$PYPI_USERNAME" --repository-url "$TWINE_UPLOAD_URL" dist/*
207+
# Publish with "trusted publisher" mechanism:
208+
# https://docs.pypi.org/trusted-publishers/
209+
#
210+
# Requires GHA token permission (above in YAML) and PyPI magement:
211+
# https://test.pypi.org/manage/project/otdf-python/settings/publishing/
212+
- name: Publish package distributions to PyPI
213+
uses: pypa/gh-action-pypi-publish@release/v1
214+
with:
215+
repository-url: https://test.pypi.org/legacy/
216+
packages-dir: dist/
215217

216218
- uses: ncipollo/release-action@v1
217219
with:
218220
artifacts: |
219221
README.md,
220222
dist/*.whl
221223
body: otdf_python version ${{ env.PROJECT_VESION }}
224+
makeLatest: "false"
222225
tag: "${{ env.PROJECT_VESION }}-dev-${{ github.sha }}"
223226
# tag: v${{ env.PROJECT_VESION }}

0 commit comments

Comments
 (0)