Release 2024.08.03 #31
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Distributed under the MIT License. | |
# See LICENSE.txt for details. | |
# Automations that run on published releases | |
name: Post release | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
tag_name: | |
description: 'Tag name of the release' | |
required: true | |
jobs: | |
add_spack_version: | |
name: Add version to Spack | |
# Checksum the new release and send a PR to Spack that adds the new version. | |
# The 'sxs-bot' GitHub account is the author of the commit and the PR. | |
# - This job requires a repository secret named `GH_TOKEN_SXSBOT_SPACK` that | |
# has write access to the `sxs-bot/spack` repository. | |
runs-on: ubuntu-latest | |
env: | |
RELEASE_TAG_NAME: ${{ inputs.tag_name || github.event.release.tag_name }} | |
steps: | |
- name: Download Spack | |
uses: actions/checkout@v4 | |
with: | |
repository: spack/spack | |
fetch-depth: 0 | |
token: ${{ secrets.GH_TOKEN_SXSBOT_SPACK }} | |
- name: Add spack-python to path | |
run: | | |
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH | |
- name: Checksum new version | |
# Download and checksum the release tarball, and add a line to Spack's | |
# `spectre/package.py`` file with the new version. | |
# | |
# The package file defines versions in lines like this: | |
# | |
# version('develop', branch='develop') | |
# version('2022.01.03', sha256='872a0d1...') | |
# ... | |
# | |
# The `spack.util.format.get_version_lines` function returns a string | |
# with lines like this for the new version(s), including the correct | |
# indentation. Therefore, we insert the new lines into the file right | |
# below the 'develop' version. | |
shell: spack-python {0} | |
run: | | |
import spack.spec | |
import spack.stage | |
import spack.repo | |
import spack.util.format | |
import os | |
# The tag name includes the 'v' prefix | |
release_name = '${{ env.RELEASE_TAG_NAME }}'[1:] | |
# Get the URL for the release tarball. The | |
# 'github.event.release.tarball_url' points to a slightly different | |
# 'https://api.github.com/...' URL, which has a different checksum | |
# than the tarball listed on the GitHub release page and used by | |
# Spack. | |
pkg_cls = spack.repo.PATH.get_pkg_class('spectre') | |
pkg = pkg_cls(spack.spec.Spec('spectre')) | |
release_url = pkg.url_for_version(release_name) | |
url_dict = { | |
release_name: release_url, | |
} | |
version_hashes = spack.stage.get_checksums_for_versions( | |
url_dict, | |
pkg.name, | |
fetch_options=pkg.fetch_options, | |
) | |
version_lines = spack.util.format.get_version_lines( | |
version_hashes, url_dict | |
) | |
package_file = os.path.join(pkg.package_dir, 'package.py') | |
with open(package_file, 'r') as open_package_file: | |
package_file_lines = open_package_file.readlines() | |
with open(package_file, 'w') as open_package_file: | |
for line in package_file_lines: | |
open_package_file.write(line) | |
if line.strip().startswith('version("develop"'): | |
open_package_file.write(version_lines + "\n") | |
- name: Fix code formatting | |
run: | | |
spack style --fix `git diff --name-only` | |
# Formatting can also be fixed later by Spack maintainers in the PR, so | |
# it's fine if it fails here for some reason | |
continue-on-error: true | |
- name: Print diff | |
run: | | |
git diff | |
- name: Send pull request to Spack | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GH_TOKEN_SXSBOT_SPACK }} | |
commit-message: "spectre: add ${{ env.RELEASE_TAG_NAME }}" | |
committer: "sxs-bot <[email protected]>" | |
branch: "spectre-${{ env.RELEASE_TAG_NAME }}" | |
delete-branch: true | |
push-to-fork: sxs-bot/spack | |
title: "spectre: add ${{ env.RELEASE_TAG_NAME }}" | |
body: "" | |
# Build and push the `demo` container to DockerHub on releases. This is | |
# because the `demo` container has pre-built executables that we want to keep | |
# up to date. | |
docker: | |
uses: ./.github/workflows/DemoContainer.yaml | |
secrets: inherit |