Skip to content

Build

Build #404

Workflow file for this run

# Nightly builds
name: Build
on:
schedule:
- cron: "15 0 * * *"
permissions:
contents: read
packages: read
concurrency: build
env:
GIT_AUTHOR_NAME: OpenSlide Automation
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: OpenSlide Automation
GIT_COMMITTER_EMAIL: [email protected]
jobs:
setup:
name: Set up
runs-on: ubuntu-latest
outputs:
linux_builder_repo_and_digest: ${{ steps.find-linux.outputs.builder_repo_and_digest }}
windows_builder_repo_and_digest: ${{ steps.find-windows.outputs.builder_repo_and_digest }}
suffix: ${{ steps.params.outputs.suffix }}
openslide_commit: ${{ steps.params.outputs.openslide_commit }}
bin_commit: ${{ steps.params.outputs.bin_commit }}
changed: ${{ steps.params.outputs.changed }}
stale: ${{ steps.params.outputs.stale }}
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Find Linux builder container digest
id: find-linux
uses: openslide/openslide-bin/.github/find-container-digest@main
with:
builder_image: linux
- name: Find Windows builder container digest
id: find-windows
uses: openslide/openslide-bin/.github/find-container-digest@main
with:
builder_image: windows
- name: Calculate parameters
id: params
run: |
set -euo pipefail
suffix="$(date +%Y%m%d).nightly"
echo "suffix=$suffix" >> $GITHUB_OUTPUT
duplicate=$(jq ".builds[] | select(.version | endswith(\"+$suffix\"))" \
site/index.json)
if [ -n "$duplicate" ]; then
echo "Found existing nightly build with suffix $suffix"
exit 1
fi
# Modify the repository at least every 30 days so GitHub doesn't
# disable the workflow
if [ $(( $(jq .last_update site/index.json) + 86400 * 30 )) -lt $(date +%s) ]; then
echo "Repository is stale"
echo "stale=true" >> $GITHUB_OUTPUT
fi
for repo in openslide openslide-bin; do
old=$(jq -r ".builds[-1][\"${repo}\"]" site/index.json)
new=$(curl --no-progress-meter \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/openslide/${repo}/commits/main" |
jq -r .sha)
echo "$repo commit: https://github.com/openslide/${repo}/commit/${new:0:10}"
echo "${repo##*-}_commit=$new" >> $GITHUB_OUTPUT
if [ "$old" != "$new" ]; then
echo " -> changed from https://github.com/openslide/${repo}/commit/${old:0:10}"
echo "changed=true" >> $GITHUB_OUTPUT
else
echo " -> unchanged"
fi
done
for repo in "linux|${{ steps.find-linux.outputs.builder_repo_and_digest }}" "windows|${{ steps.find-windows.outputs.builder_repo_and_digest }}"; do
name="${repo%%|*}"
old=$(jq -r ".builds[-1][\"${name}-builder\"]" site/index.json)
new="${repo##*|}"
echo "$name builder container: $new"
if [ "$old" != "$new" ]; then
echo " -> changed from $old"
echo "changed=true" >> $GITHUB_OUTPUT
else
echo " -> unchanged"
fi
done
build:
name: Build
needs: setup
if: needs.setup.outputs.changed
uses: openslide/openslide-bin/.github/workflows/build.yml@main
with:
linux_builder_repo_and_digest: ${{ needs.setup.outputs.linux_builder_repo_and_digest }}
macos_enable: true
windows_builder_repo_and_digest: ${{ needs.setup.outputs.windows_builder_repo_and_digest }}
openslide_repo: openslide/openslide
openslide_ref: ${{ needs.setup.outputs.openslide_commit }}
openslide_bin_repo: openslide/openslide-bin
openslide_bin_ref: ${{ needs.setup.outputs.bin_commit }}
suffix: ${{ needs.setup.outputs.suffix }}
upload:
name: Upload
needs: [setup, build]
if: needs.setup.outputs.changed
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Update Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Check out repo
uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install python3-dateutil python3-jinja2
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: "openslide[_-]bin-*"
path: upload
merge-multiple: true
- name: Update index
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
scripts/make-index.py \
--version "${{ needs.build.outputs.version }}" \
--files upload \
--linux-builder "${{ needs.setup.outputs.linux_builder_repo_and_digest }}" \
--windows-builder "${{ needs.setup.outputs.windows_builder_repo_and_digest }}" \
--openslide "${{ needs.setup.outputs.openslide_commit }}" \
--bin "${{ needs.setup.outputs.bin_commit }}"
- name: Commit, tag, push, create release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
version="${{ needs.build.outputs.version }}"
tar xf "upload/openslide-bin-${version}.tar.gz"
title="Build $version"
# trim width for commit message limit
body="$(openslide-bin-${version}/bintool versions \
upload/*.{tar.xz,zip} | \
sed 's/ |$/|/')"
git add site
git commit -m "$title" -m "$body"
git tag -a "v$version" -m "$title" -m "$body"
git push origin HEAD "v$version"
gh release create --notes-file - --prerelease --verify-tag \
--title "$title" "v$version" upload/* <<EOF
See the [build index](https://openslide.org/builds/) for more info.
$body
EOF
deploy:
name: Deploy website
needs: [upload]
permissions:
contents: read
pages: write
id-token: write
uses: ./.github/workflows/pages.yml
keepalive:
name: Keepalive
needs: setup
if: needs.setup.outputs.stale && ! needs.setup.outputs.changed
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install python3-dateutil python3-jinja2
- name: Commit and push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
scripts/make-index.py
git add site
git commit -m "Update timestamp"
git push