Skip to content

Commit 9e29ca9

Browse files
committed
cicd: change pypi publishing to trusted publisher
Adding an Equinor user to avoid relying on single indivisuals, and avoid pwd/token with trusted publishing. Refs: equinor/ecalc-internal#433
1 parent 76adb32 commit 9e29ca9

2 files changed

Lines changed: 35 additions & 29 deletions

File tree

.github/workflows/publish.yml

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,63 @@ name: Publish libeCalc package to PyPI
22

33
on:
44
workflow_call:
5-
secrets:
6-
PYPI_TOKEN:
7-
required: true
8-
9-
workflow_dispatch: # Trigger manually, if needed
10-
11-
permissions:
12-
packages: write
13-
contents: read
14-
id-token: write
5+
workflow_dispatch:
156

167
jobs:
178
publish:
9+
environment:
10+
name: testpypi
11+
url: https://test.pypi.org/p/libecalc # TODO: test
12+
#name: pypi
13+
#url: https://pypi.org/project/libecalc/
14+
permissions:
15+
id-token: write # Required for Trusted Publishing to PyPI, the pypa action uses this
1816
runs-on: ubuntu-24.04
1917
steps:
2018
- name: Checkout code
2119
uses: actions/checkout@v4
22-
with:
20+
#with:
2321
# Make sure we publish from main branch, not the triggering ref
24-
ref: ${{ github.event.repository.default_branch }}
22+
# ref: ${{ github.event.repository.default_branch }}
2523

2624
- name: Setup Python 3.11
2725
uses: actions/setup-python@v5
2826
with:
2927
python-version: '3.11'
3028

29+
# TODO: Change to uv
3130
- uses: snok/install-poetry@v1
3231
with:
3332
version: 1.8.4
3433
virtualenvs-create: true
3534

35+
# TODO: Needed? Should have done waaaay earlier, ie. before we are allowed to create a new release
3636
- name: Check pyproject.toml validity
3737
run: poetry check --no-interaction
3838

39-
- name: Cache dependencies
40-
id: cache-deps
41-
uses: actions/cache@v4
42-
with:
43-
path: ${{github.workspace}}/.venv
44-
key: poetry-${{ hashFiles('**/poetry.lock') }}
45-
restore-keys: poetry-
39+
# TODO: Needed, we do this to validate? In case sth happened between the lock file was ok and now? withdrawn deps? To build, ie. find packages to allow building, prob. yes, but test to verify!
40+
# - name: Cache dependencies
41+
# id: cache-deps
42+
# uses: actions/cache@v4
43+
# with:
44+
# path: ${{github.workspace}}/.venv
45+
# key: poetry-${{ hashFiles('**/poetry.lock') }}
46+
# restore-keys: poetry-
4647

47-
- name: Install dependencies # if cache has changed
48-
if: steps.cache-deps.cache-hit != 'true'
48+
# - name: Install dependencies # if cache has changed
49+
# if: steps.cache-deps.cache-hit != 'true'
50+
# run: |
51+
# poetry config virtualenvs.in-project true
52+
# poetry install --no-interaction
53+
54+
- name: Build the libecalc package (wheel and sdist by default)
4955
run: |
50-
poetry config virtualenvs.in-project true
51-
poetry install --no-interaction
56+
poetry build
5257
5358
- name: Publish to PyPI
54-
env:
55-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
56-
run: |
57-
poetry config pypi-token.pypi $PYPI_TOKEN
58-
poetry publish --build
59+
uses: pypa/gh-action-pypi-publish@release/v1
60+
with:
61+
# attestations: false
62+
repository-url: https://test.pypi.org/legacy/
63+
packages-dir: dist/
64+
clear-previous-versions: true

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
name = "libecalc"
33
# DO_NOT_EDIT: Version number automatically changed in CICD
4-
version = "10.0.5" # x-release-please-version
4+
version = "10.0.6" # x-release-please-version
55
# END_DO_NOT_EDIT
66
description = "eCalc™ is a software tool for calculation of energy demand and greenhouse gas (GHG) emissions from oil and gas production and processing."
77
keywords = ["energy", "emission", "scientific", "engineering"]

0 commit comments

Comments
 (0)