Skip to content
60 changes: 60 additions & 0 deletions .github/workflows/assets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release Assets

# Attaches the examples and the notebooks, as zip files, to a GitHub release.

on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: >-
Release tag to attach the zips to, such as v2.4.1. The zips are built from
that tag. Leave blank to build the artifacts only.
required: false
default: ""

permissions:
contents: write

env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"

jobs:
package:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v7
with:
# the tag when attaching to a release, otherwise the ref that triggered this
ref: ${{ inputs.tag || github.ref }}

- name: Create zip artifacts
run: |
mkdir -p dist
rm -f dist/mvtb_examples.zip dist/mvtb_notebooks.zip
zip -r dist/mvtb_examples.zip examples -x '*/__pycache__/*'
zip -r dist/mvtb_notebooks.zip docs/notebooks -x '*/__pycache__/*'

- name: Upload workflow artifacts
uses: actions/upload-artifact@v7
with:
name: mvtb-artifacts
path: |
dist/mvtb_examples.zip
dist/mvtb_notebooks.zip

# A release made by release-please does not fire the `release` event (events
# made with GITHUB_TOKEN start no workflows), so release-please.yml dispatches
# this workflow with the tag. The `release` event still covers a release made
# by hand.
- name: Upload artifacts to release
if: github.event_name == 'release' || inputs.tag != ''
uses: softprops/action-gh-release@v3

Check warning on line 55 in .github/workflows/assets.yml

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

.github/workflows/assets.yml#L55

An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release.
with:
tag_name: ${{ inputs.tag || github.event.release.tag_name }}
files: |
dist/mvtb_examples.zip
dist/mvtb_notebooks.zip
7 changes: 6 additions & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ jobs:
# `${{ steps.release.outputs.releases_created }}` is truthy on every
# push, not just when a release was actually created. Must compare
# explicitly against the string 'true'.
- name: Trigger PyPI publish
#
# The same goes for the zips of the examples and notebooks: assets.yml is
# dispatched with the tag. It runs from main, since it has no environment
# rule to satisfy, and builds the zips from the tag.
- name: Trigger PyPI publish and the release zips
if: ${{ steps.release.outputs.releases_created == 'true' }}
run: |
tag=$(gh release list --repo "$GH_REPO" --limit 1 --json tagName -q '.[0].tagName')
gh workflow run release.yml --repo "$GH_REPO" --ref "$tag"
gh workflow run assets.yml --repo "$GH_REPO" --ref main -f tag="$tag"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
Loading