Skip to content

Commit b53ae13

Browse files
committed
created binary tarballs that attach to the dev release.
1 parent d69d291 commit b53ae13

4 files changed

Lines changed: 372 additions & 12 deletions

File tree

.github/workflows/dev_release.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ jobs:
4545
git tag -f "${TAG_NAME}" "${GITHUB_SHA}"
4646
git push --force origin "refs/tags/${TAG_NAME}"
4747
48-
- name: Delete existing release (if any)
49-
env:
50-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51-
run: |
52-
gh release view "${TAG_NAME}" >/dev/null 2>&1 && \
53-
gh release delete "${TAG_NAME}" -y || \
54-
echo "No existing release to delete"
55-
5648
- name: Create/Update release
5749
uses: ncipollo/release-action@v1
5850
with:
@@ -64,4 +56,5 @@ jobs:
6456
bodyFile: /tmp/release_notes.md
6557
prerelease: true
6658
allowUpdates: true
59+
replacesArtifacts: false
6760
artifactErrorsFailBuild: false

.github/workflows/dockers_deploy_and_test.yml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Deploy and Test
33
run-name: >-
44
${{ github.event_name == 'workflow_dispatch' && 'pygemc workflow dispatch' || github.ref_name }}
55
permissions:
6-
contents: read
6+
contents: write
77
packages: write
88

99
# default versions. This is overwritten by distros_tags.sh
@@ -124,6 +124,8 @@ jobs:
124124
-t "${{ matrix.image_tag }}" \
125125
--gemc-version "${{ matrix.gemc_tag || env.GEMC_TAG }}" \
126126
--geant4-version "${{ matrix.geant4_tag || env.GEANT4_TAG }}" \
127+
--with-package \
128+
--package-arch "${{ matrix.arch }}" \
127129
> Dockerfile.generated
128130
cat Dockerfile.generated
129131
@@ -165,6 +167,17 @@ jobs:
165167
cache-from: ${{ env.CACHE_REF }}
166168
outputs: type=local,dest=${{ runner.temp }}/artifacts/${{ matrix.logs_dir }}
167169

170+
- name: Export GEMC tarball (runner artifact)
171+
uses: docker/build-push-action@v7
172+
with:
173+
pull: true
174+
context: .
175+
file: ./Dockerfile.generated
176+
target: package-export
177+
push: false
178+
cache-from: ${{ env.CACHE_REF }}
179+
outputs: type=local,dest=${{ runner.temp }}/artifacts/package-${{ env.LOGNAME }}
180+
168181
- name: Pack logs
169182
shell: bash
170183
run: |
@@ -181,6 +194,44 @@ jobs:
181194
path: ${{ env.LOG_TAR }}
182195
if-no-files-found: ignore
183196

197+
- name: Upload GEMC tarball artifact
198+
uses: actions/upload-artifact@v7
199+
with:
200+
name: gemc-tarball-${{ env.LOGNAME }}
201+
path: ${{ runner.temp }}/artifacts/package-${{ env.LOGNAME }}/*.tar.gz
202+
if-no-files-found: error
203+
204+
release_tarballs:
205+
if: ${{ github.event_name != 'pull_request' && always() }}
206+
name: Attach GEMC tarballs to dev release
207+
needs: [ build_arch, discover ]
208+
runs-on: ubuntu-latest
209+
env:
210+
TAG_NAME: dev
211+
steps:
212+
- name: Download GEMC tarballs
213+
uses: actions/download-artifact@v7
214+
with:
215+
pattern: gemc-tarball-*
216+
path: ${{ runner.temp }}/gemc-release-artifacts
217+
merge-multiple: true
218+
219+
- name: Upload GEMC tarballs to release
220+
env:
221+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
222+
shell: bash
223+
run: |
224+
shopt -s nullglob
225+
tarballs=("${{ runner.temp }}/gemc-release-artifacts/"*.tar.gz)
226+
shopt -u nullglob
227+
if (( ${#tarballs[@]} == 0 )); then
228+
echo "No GEMC tarballs found"
229+
exit 1
230+
fi
231+
gh release view "${TAG_NAME}" >/dev/null 2>&1 || \
232+
gh release create "${TAG_NAME}" --title "Dev Nightly" --prerelease --notes "Dev nightly release."
233+
gh release upload "${TAG_NAME}" "${tarballs[@]}" --clobber
234+
184235
185236
# Manifest stitch
186237
# uses matrix_manifest so it's not repeated for each arch

ci/dockerfile_creator.py

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,16 @@ def docker_header(image: str, image_tag: str, geant4_tag: str) -> str:
3535
return commands
3636

3737

38-
def install_gemc(geant4_version: str, gemc_version: str) -> str:
38+
def install_gemc(geant4_version: str, gemc_version: str, source: str) -> str:
39+
if source == "context":
40+
commands = f'\nCOPY . /root/src \n'
41+
commands += f'RUN cd /root/src \\\n'
42+
commands += f" && DOCKER_ENTRYPOINT_SOURCE_ONLY=1 . {remote_entrypoint()} \\\n"
43+
commands += f' && module load geant4/{geant4_version} \\\n'
44+
commands += f' && ./ci/build.sh \\\n'
45+
commands += f' && echo "export PATH=\\${{SIM_HOME}}/gemc/dev/bin:\\${{SIM_HOME}}/gemc/dev/python_env/bin:\\${{PATH}}" >> {remote_entrypoint_addon()} \n'
46+
return commands
47+
3948
clone_arguments = f'-c advice.detachedHead=false --recurse-submodules --single-branch'
4049
if gemc_version == "dev":
4150
clone_arguments += ' --depth 1'
@@ -50,18 +59,48 @@ def install_gemc(geant4_version: str, gemc_version: str) -> str:
5059
return commands
5160

5261

62+
def package_install(geant4_version: str, gemc_version: str, image: str, image_tag: str, package_arch: str) -> str:
63+
package_name = f'gemc-{gemc_version}-geant4-{geant4_version}-{image}-{image_tag}-{package_arch}'
64+
commands = '\n# release tarball build \n'
65+
commands += 'FROM final AS package-build \n'
66+
commands += f'RUN cd /root/src \\\n'
67+
commands += f" && DOCKER_ENTRYPOINT_SOURCE_ONLY=1 . {remote_entrypoint()} \\\n"
68+
commands += f' && module load geant4/{geant4_version} \\\n'
69+
commands += f' && GEANT4_VERSION={geant4_version} GEMC_PACKAGE_VERSION={gemc_version} \\\n'
70+
commands += f' ./ci/package_install.sh "${{SIM_HOME}}/gemc/dev" /root/src/dist "{package_name}" \n'
71+
return commands
72+
73+
5374
def log_exporters() -> str:
5475
commands = '\n# logs exporter \n'
5576
commands += 'FROM scratch AS logs-export \n'
5677
commands += 'COPY --from=final /root/src/logs /logs \n'
5778
return commands
5879

5980

60-
def create_dockerfile(image: str, image_tag: str, geant4_version: str, gemc_version: str) -> str:
81+
def package_exporters() -> str:
82+
commands = '\n# release package exporter \n'
83+
commands += 'FROM scratch AS package-export \n'
84+
commands += 'COPY --from=package-build /root/src/dist / \n'
85+
return commands
86+
87+
88+
def create_dockerfile(
89+
image: str,
90+
image_tag: str,
91+
geant4_version: str,
92+
gemc_version: str,
93+
with_package: bool = False,
94+
source: str = "clone",
95+
package_arch: str = "amd64",
96+
) -> str:
6197
commands = ""
6298
commands += docker_header(image, image_tag, geant4_version)
63-
commands += install_gemc(geant4_version, gemc_version)
99+
commands += install_gemc(geant4_version, gemc_version, source)
64100
commands += log_exporters()
101+
if with_package:
102+
commands += package_install(geant4_version, gemc_version, image, image_tag, package_arch)
103+
commands += package_exporters()
65104

66105
return commands
67106

@@ -92,6 +131,18 @@ def main():
92131
"--gemc-version", default="dev",
93132
help="Version of GEMC to install (default: %(default)s)"
94133
)
134+
parser.add_argument(
135+
"--with-package", action="store_true",
136+
help="Add a package-export stage that emits a GEMC install tarball"
137+
)
138+
parser.add_argument(
139+
"--source", choices=["clone", "context"], default="clone",
140+
help="Build GEMC from a GitHub clone or from the Docker build context"
141+
)
142+
parser.add_argument(
143+
"--package-arch", choices=["amd64", "arm64"], default="amd64",
144+
help="Architecture suffix to use in the package artifact name"
145+
)
95146

96147
args = parser.parse_args()
97148

@@ -107,6 +158,9 @@ def main():
107158
args.image_tag,
108159
args.geant4_version,
109160
args.gemc_version,
161+
args.with_package,
162+
args.source,
163+
args.package_arch,
110164
)
111165
print(dockerfile)
112166

0 commit comments

Comments
 (0)