From 5437e062e19ffa95096c059122b3a82699bce3b3 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Tue, 3 Feb 2026 14:49:14 +0100 Subject: [PATCH] feat(ci): add release workflow --- .gitea/scripts/create-release.sh | 73 ++++++++++++++++++++++++++++++++ .gitea/workflows/deploy.yaml | 60 -------------------------- .gitea/workflows/release.yaml | 53 +++++++++++++++++++++++ 3 files changed, 126 insertions(+), 60 deletions(-) create mode 100644 .gitea/scripts/create-release.sh delete mode 100644 .gitea/workflows/deploy.yaml create mode 100644 .gitea/workflows/release.yaml diff --git a/.gitea/scripts/create-release.sh b/.gitea/scripts/create-release.sh new file mode 100644 index 0000000..cf7583d --- /dev/null +++ b/.gitea/scripts/create-release.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +set -euo pipefail + +TAG="$GITHUB_REF_NAME" +VERSION="${TAG#v}" +DATE=$(date +%Y-%m-%d) + +echo "๐Ÿš€ Creating release for $TAG (safe mode)" + +# ------------------------------------------------------------------- +# 1. Extract release notes from annotated tag +# ------------------------------------------------------------------- + +NOTES=$(git tag -l "$TAG" --format='%(contents)') + +if [ -z "$NOTES" ]; then + echo "โŒ Tag message is empty" + exit 1 +fi + +git checkout main + +# ------------------------------------------------------------------- +# 2. Update all package.json versions +# ------------------------------------------------------------------- + +echo "๐Ÿ”ง Updating package.json versions to $VERSION" + +find . -name package.json -not -path "*/node_modules/*" | while read -r file; do + jq --arg v "$VERSION" '.version = $v' "$file" >"$file.tmp" + mv "$file.tmp" "$file" +done + +# ------------------------------------------------------------------- +# 3. Update CHANGELOG.md (prepend) +# ------------------------------------------------------------------- + +{ + echo "## $TAG ($DATE)" + echo "" + echo "$NOTES" + echo "" + echo "---" + echo "" + cat CHANGELOG.md 2>/dev/null || true +} >CHANGELOG.tmp + +mv CHANGELOG.tmp CHANGELOG.md + +# ------------------------------------------------------------------- +# 4. Create release commit +# ------------------------------------------------------------------- + +git config user.name "release-bot" +git config user.email "release-bot@ci" + +git add CHANGELOG.md $(find . -name package.json -not -path "*/node_modules/*") + +# Skip commit if nothing changed +if git diff --cached --quiet; then + echo "No changes to commit for release $TAG" + exit 0 +fi + +git commit -m "chore(release): $TAG" + +# ------------------------------------------------------------------- +# 5. Push changes +# ------------------------------------------------------------------- + +git push origin main + +echo "โœ… Release commit for $TAG created successfully (tag untouched)" diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml deleted file mode 100644 index fa42f30..0000000 --- a/.gitea/workflows/deploy.yaml +++ /dev/null @@ -1,60 +0,0 @@ -name: ๐Ÿ—๏ธ Build and Deploy - -on: - push: - branches: ["*"] - -env: - PNPM_CACHE_FOLDER: ~/.pnpm-store - -jobs: - build_and_deploy: - runs-on: ubuntu-latest - container: jimfx/nodes:latest - steps: - - name: ๐Ÿ“‘ Checkout Code - uses: actions/checkout@v4 - - - name: ๐Ÿ’พ Setup pnpm Cache - uses: actions/cache@v4 - with: - path: ${{ env.PNPM_CACHE_FOLDER }} - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm- - - - name: ๐Ÿ“ฆ Install Dependencies - run: pnpm install --frozen-lockfile --store-dir ${{ env.PNPM_CACHE_FOLDER }} - - - name: ๐Ÿงน Run Linter - run: pnpm lint - - - name: ๐ŸŽจ Check Formatting - run: pnpm format:check - - - name: ๐Ÿงฌ Type Check - run: pnpm check - - - name: ๐Ÿ› ๏ธ Build Site - run: pnpm run build:deploy - - - name: ๐Ÿ”‘ Configure rclone - if: github.ref == 'refs/heads/main' - run: | - echo "$SSH_PRIVATE_KEY" > /tmp/id_rsa - chmod 600 /tmp/id_rsa - mkdir -p ~/.config/rclone - echo -e "[sftp-remote]\ntype = sftp\nhost = ${SSH_HOST}\nuser = ${SSH_USER}\nport = ${SSH_PORT}\nkey_file = /tmp/id_rsa" > ~/.config/rclone/rclone.conf - env: - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - SSH_HOST: ${{ vars.SSH_HOST }} - SSH_PORT: ${{ vars.SSH_PORT }} - SSH_USER: ${{ vars.SSH_USER }} - - - name: ๐Ÿš€ Deploy Changed Files via rclone - if: github.ref == 'refs/heads/main' - run: | - echo "Uploading the rest" - rclone sync --update -v --progress --exclude _astro/** --stats 2s --stats-one-line ./app/build/ sftp-remote:${REMOTE_DIR} --transfers 4 - env: - REMOTE_DIR: ${{ vars.REMOTE_DIR }} diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..09f2c40 --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,53 @@ +name: ๐Ÿš€ Release + +env: + PNPM_CACHE_FOLDER: ~/.pnpm-store + +jobs: + release: + runs-on: ubuntu-latest + container: jimfx/nodes:latest + + steps: + - name: ๐Ÿ“‘ Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: ๐Ÿ’พ Setup pnpm Cache + uses: actions/cache@v4 + with: + path: ${{ env.PNPM_CACHE_FOLDER }} + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- + + - name: ๐Ÿ“ฆ Install Dependencies + run: pnpm install --frozen-lockfile --store-dir ${{ env.PNPM_CACHE_FOLDER }} + + - name: ๐Ÿงน Lint + run: pnpm lint + + - name: ๐ŸŽจ Format Check + run: pnpm format:check + + - name: ๐Ÿงฌ Type Check + run: pnpm check + + - name: ๐Ÿ› ๏ธ Build + run: pnpm build:deploy + + - name: ๐Ÿš€ Create Release Commit + if: github.ref_type == 'tag' + run: ./.gitea/scripts/create-release.sh + + - name: ๐Ÿท๏ธ Create Gitea Release + if: github.ref_type == 'tag' + uses: akkuman/gitea-release-action@v1 + with: + tag_name: ${{ github.ref_name }} + release_name: Release ${{ github.ref_name }} + body_path: CHANGELOG.md + draft: false + prerelease: false