Release Check #18
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
name: Release Check | |
on: | |
# Allow manual trigger for testing | |
workflow_dispatch: | |
jobs: | |
prepare: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
last_release: ${{ steps.last-release.outputs.hash }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Find package directories | |
id: set-matrix | |
run: | | |
DIRS=$(git ls-tree -r HEAD --name-only | grep -E "package.json|pyproject.toml" | xargs dirname | grep -v "^.$" | jq -R -s -c 'split("\n")[:-1]') | |
echo "matrix=${DIRS}" >> $GITHUB_OUTPUT | |
- name: Get last release hash | |
id: last-release | |
run: | | |
HASH=$(git rev-list --tags --max-count=1 || echo "HEAD~1") | |
echo "hash=${HASH}" >> $GITHUB_OUTPUT | |
check-release: | |
needs: prepare | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
directory: ${{ fromJson(needs.prepare.outputs.matrix) }} | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: astral-sh/setup-uv@v5 | |
- name: Setup Node.js | |
if: endsWith(matrix.directory, 'package.json') | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Setup Python | |
if: endsWith(matrix.directory, 'pyproject.toml') | |
run: uv python install | |
- name: Check release | |
id: check | |
run: | | |
dir_hash=$(echo "${{ matrix.directory }}" | sha256sum --quiet) | |
output=$(uv run --script scripts/release.py --dry-run "${{ matrix.directory }}" "${{ needs.prepare.outputs.last_release }}" | grep -o -E "[a-zA-Z0-9\-]+@[0-9]+\.[0-9]+\.[0-9]+" || true) | |
if [ ! -z "$output" ]; then | |
mkdir -p ./outputs | |
echo "$output" > "./outputs/${dir_hash}" | |
fi | |
- uses: actions/upload-artifact@v4 | |
if: steps.check.outputs.release | |
with: | |
name: release-outputs-${{ matrix.directory }} | |
path: ./outputs/${{ matrix.directory }} | |
check-tag: | |
needs: [prepare, check-release] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: release-outputs-* | |
merge-multiple: true | |
path: outputs | |
- name: Simulate tag creation | |
run: | | |
ls -lh outputs | |
if [ -d outputs ]; then | |
cat outputs/* > packages.txt | |
if [ -s packages.txt ]; then | |
DATE=$(date +%Y.%m.%d) | |
echo "🔍 Dry run: Would create tag v${DATE} if this was a real release" | |
echo "# Release ${DATE}" > notes.md | |
echo "" >> notes.md | |
echo "## Updated Packages" >> notes.md | |
while IFS= read -r line; do | |
echo "- $line" >> notes.md | |
done < packages.txt | |
echo "🔍 Would create release with following notes:" | |
cat notes.md | |
fi | |
fi |