Skip to content

Commit b8da78f

Browse files
committed
Add cd
1 parent 5284024 commit b8da78f

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

.github/workflows/cd.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CD
2+
3+
# Must select "Read and write permissions" in GitHub → Repo → Settings → Actions → General → Workflow permissions
4+
5+
6+
on:
7+
push:
8+
branches: [ main, master ]
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@master
16+
with:
17+
fetch-depth: 0 # To fetch all history for tags
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '22'
23+
24+
- name: Tag and release
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
run: |
28+
git config --global user.name "github-actions[bot]"
29+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
30+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
31+
./scripts/release.sh

scripts/release.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# Release script for release.yaml (a GitHub Action)
4+
# Can be run locally as well if desired
5+
# It creates a tag based on the version in pyproject.toml and creates a GitHub release based on the tag
6+
7+
set -e
8+
cd "$(dirname "$0")"/..
9+
10+
tag=$(node -p "require('./package.json').version")
11+
12+
tagged=$(git tag -l $tag)
13+
if [ -z "$tagged" ]; then
14+
git tag -a "$tag" -m "Release $tag"
15+
git push origin "$tag"
16+
echo "Tagged release $tag"
17+
18+
gh release create "$tag" \
19+
--repo="$GITHUB_REPOSITORY" \
20+
--title="$tag" \
21+
--generate-notes
22+
echo "Created release"
23+
24+
# Release to ...
25+
26+
else
27+
echo "Tag $tag already exists"
28+
fi

0 commit comments

Comments
 (0)