Skip to content

Commit 71c7908

Browse files
committed
Major refactoring of the "build" workflow
Currently the Maven/SciJava part is disabled until testing of the changes is completed. With the modifications this will now also build and publish the Python flavor package on PyPi, and will trigger the "deploy-pages" workflow in the 'imcf/imcf.github.io' repo.
1 parent d974dd5 commit 71c7908

1 file changed

Lines changed: 148 additions & 20 deletions

File tree

β€Ž.github/workflows/build.ymlβ€Ž

Lines changed: 148 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,163 @@
1-
name: build
1+
name: 🚚🌍 Publish to πŸ”¬β˜• SciJava and πŸŽͺ PyPI
22

33
on:
4+
workflow_dispatch:
5+
46
push:
57
branches:
68
- master
79
tags:
8-
- "*-[0-9]+.*"
10+
- "python-imcflibs-[0-9]+.*"
911
pull_request:
1012
branches:
1113
- master
1214

15+
1316
jobs:
14-
build:
17+
18+
# publish-to-scijava:
19+
20+
# name: πŸ”¬β˜• publish via β“‚ Maven to SciJava
21+
22+
# runs-on: ubuntu-latest
23+
24+
# steps:
25+
26+
# - uses: actions/checkout@v4
27+
# name: πŸ“₯ Checkout repo
28+
29+
# - name: β˜• Set up Java
30+
# uses: actions/setup-java@v3
31+
# with:
32+
# java-version: '8'
33+
# distribution: 'zulu'
34+
# cache: 'maven'
35+
36+
# - name: πŸͺ Set up CI environment
37+
# run: .github/setup.sh
38+
39+
# - name: πŸ‘· Build and publish on πŸ”¬β˜• SciJava
40+
# run: .github/build.sh
41+
# env:
42+
# GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
43+
# GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
44+
# MAVEN_USER: ${{ secrets.MAVEN_USER }}
45+
# MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
46+
# OSSRH_PASS: ${{ secrets.OSSRH_PASS }}
47+
# SIGNING_ASC: ${{ secrets.SIGNING_ASC }}
48+
49+
50+
build-via-poetry:
51+
52+
name: πŸ‘· build via 🎭 Poetry
53+
54+
runs-on: ubuntu-22.04
55+
56+
steps:
57+
- uses: actions/checkout@v4
58+
name: πŸ“₯ Checkout repo
59+
60+
- name: πŸ•΅ Inspect if this is a proper "scijava-scripts" release
61+
run: scripts/check-if-release.sh
62+
63+
- name: 🐍 Set up Python
64+
uses: actions/setup-python@v5
65+
with:
66+
python-version: "3.10"
67+
68+
- name: πŸ—ƒ Cache 🎭 Poetry install
69+
uses: actions/cache@v4
70+
with:
71+
path: ~/.local
72+
key: poetry-2.0.1-0
73+
74+
# The key configuration value here is `virtualenvs-in-project: true`: this
75+
# creates the venv as a `.venv` in your testing directory, which allows
76+
# the next step to easily cache it.
77+
- name: πŸ”©πŸ”§ Install 🎭 Poetry
78+
uses: snok/install-poetry@v1
79+
with:
80+
version: 2.0.1
81+
virtualenvs-create: true
82+
virtualenvs-in-project: true
83+
84+
# Cache dependencies (i.e. all the stuff in your `pyproject.toml`).
85+
- name: πŸ—ƒ Cache 🧾 Dependencies
86+
id: cache-deps
87+
uses: actions/cache@v4
88+
with:
89+
path: .venv
90+
key: pydeps-${{ hashFiles('**/poetry.lock') }}
91+
92+
# No Poetry dynamic versioning in this project, we're using the POM instead!
93+
# - name: 🎭 Install Poetry dynamic-versioning πŸ”Œ plugin
94+
# run: poetry self add "poetry-dynamic-versioning[plugin]"
95+
96+
# Install dependencies. `--no-root` means "install all dependencies but
97+
# not the project itself", which is what you want to avoid caching _your_
98+
# code. The `if` statement ensures this only runs on a cache miss.
99+
- name: 🎭 Install 🧾 Dependencies
100+
run: scripts/run-poetry.sh install --no-interaction --no-root
101+
if: steps.cache-deps.outputs.cache-hit != 'true'
102+
103+
- name: 🎭 Install πŸ›– project
104+
run: scripts/run-poetry.sh install --no-interaction
105+
106+
- name: πŸŽ­πŸ‘· Build 🧱 project
107+
run: scripts/run-poetry.sh build
108+
109+
- name: πŸ“€ Upload build artifacts
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: release-dists
113+
path: dist/
114+
115+
116+
publish-to-pypi:
117+
118+
name: 🚚🌍 publish to πŸŽͺ PyPI
119+
15120
runs-on: ubuntu-latest
16121

122+
needs:
123+
- release-build
124+
125+
permissions:
126+
id-token: write
127+
128+
environment:
129+
name: release
130+
17131
steps:
18-
- uses: actions/checkout@v2
19-
- name: Set up Java
20-
uses: actions/setup-java@v3
132+
- name: πŸ“₯ Retrieve release πŸ“¦ distributions
133+
uses: actions/download-artifact@v4
21134
with:
22-
java-version: '8'
23-
distribution: 'zulu'
24-
cache: 'maven'
25-
- name: Set up CI environment
26-
run: .github/setup.sh
27-
- name: Execute the build
28-
run: .github/build.sh
29-
env:
30-
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
31-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
32-
MAVEN_USER: ${{ secrets.MAVEN_USER }}
33-
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
34-
OSSRH_PASS: ${{ secrets.OSSRH_PASS }}
35-
SIGNING_ASC: ${{ secrets.SIGNING_ASC }}
135+
name: release-dists
136+
path: dist/
137+
138+
- name: πŸ₯ Publish release distributions to πŸŽͺ PyPI
139+
uses: pypa/gh-action-pypi-publish@release/v1
140+
with:
141+
packages-dir: dist/
142+
143+
144+
trigger-foreign-workflows:
145+
146+
name: πŸš€ Dispatch foreign workflows
147+
148+
strategy:
149+
matrix:
150+
repo: ['imcf/imcf.github.io']
151+
152+
runs-on: ubuntu-latest
153+
154+
steps:
155+
- name: 🏹 Fire event on `${{ matrix.repo }}`
156+
run: |
157+
curl -L \
158+
-X POST \
159+
-H "Accept: application/vnd.github+json" \
160+
-H "Authorization: Bearer ${{ secrets.DISPATCH_DEPLOY_PAGES }}" \
161+
-H "X-GitHub-Api-Version: 2022-11-28" \
162+
https://api.github.com/repos/${{ matrix.repo }}/dispatches \
163+
-d '{"event_type":"dispatch-event"}'

0 commit comments

Comments
Β (0)