This commit is contained in:
MartinBraquet
2025-08-04 09:50:14 +02:00
parent 528402437b
commit b8da78f2fa
2 changed files with 59 additions and 0 deletions

31
.github/workflows/cd.yml vendored Normal file
View File

@@ -0,0 +1,31 @@
name: CD
# Must select "Read and write permissions" in GitHub → Repo → Settings → Actions → General → Workflow permissions
on:
push:
branches: [ main, master ]
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@master
with:
fetch-depth: 0 # To fetch all history for tags
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Tag and release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
./scripts/release.sh

28
scripts/release.sh Normal file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
# Release script for release.yaml (a GitHub Action)
# Can be run locally as well if desired
# It creates a tag based on the version in pyproject.toml and creates a GitHub release based on the tag
set -e
cd "$(dirname "$0")"/..
tag=$(node -p "require('./package.json').version")
tagged=$(git tag -l $tag)
if [ -z "$tagged" ]; then
git tag -a "$tag" -m "Release $tag"
git push origin "$tag"
echo "Tagged release $tag"
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="$tag" \
--generate-notes
echo "Created release"
# Release to ...
else
echo "Tag $tag already exists"
fi