From 3383bee968a0298a9147bb052daaf4c1591d7a0e Mon Sep 17 00:00:00 2001 From: josh Date: Sat, 28 Mar 2026 10:15:52 -0400 Subject: [PATCH] chore: replace build.yml with ci.yml + release.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Splits the single workflow into two with distinct responsibilities: ci.yml — runs tests on push/PR to dev and main. Powers the required status check for branch protection on both branches. release.yml — triggers on push to main (merged PR). Reads version from package.json, asserts the tag doesn't already exist, creates the git tag, generates patch notes from commits since the previous tag, builds and pushes the Docker image, and creates the Gitea release. No more manual git tag or git push --tags. build.yml deleted — all three of its jobs are covered by the new files. Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/build.yml | 84 ------------------------------- .gitea/workflows/ci.yml | 23 +++++++++ .gitea/workflows/release.yml | 95 ++++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 84 deletions(-) delete mode 100644 .gitea/workflows/build.yml create mode 100644 .gitea/workflows/ci.yml create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml deleted file mode 100644 index 5f168e1..0000000 --- a/.gitea/workflows/build.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: Build - -on: - push: - branches: [main] - tags: - - 'v*' - -env: - IMAGE: ${{ vars.REGISTRY_HOST }}/${{ gitea.repository_owner }}/catalyst - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 'lts/*' - cache: npm - - - name: Install dependencies - run: npm ci - - - name: Run tests - run: npm test - - build: - runs-on: ubuntu-latest - needs: test - if: startsWith(gitea.ref, 'refs/tags/v') - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.IMAGE }} - tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha,prefix=,format=short - type=raw,value=latest,enable={{is_default_branch}} - - - name: Log in to Gitea registry - uses: docker/login-action@v3 - with: - registry: ${{ vars.REGISTRY_HOST }} - username: ${{ gitea.actor }} - password: ${{ secrets.TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - - release: - runs-on: ubuntu-latest - needs: build - if: startsWith(gitea.ref, 'refs/tags/v') - - steps: - - name: Create release - run: | - curl -sf -X POST \ - -H "Authorization: token ${{ secrets.TOKEN }}" \ - -H "Content-Type: application/json" \ - "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" \ - -d "{ - \"tag_name\": \"${{ gitea.ref_name }}\", - \"name\": \"Catalyst ${{ gitea.ref_name }}\", - \"body\": \"### Image\n\n\`${{ env.IMAGE }}:${{ gitea.ref_name }}\`\", - \"draft\": false, - \"prerelease\": false - }" diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..856da66 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,23 @@ +name: CI + +on: + push: + branches: [dev, main] + pull_request: + branches: [dev, main] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + cache: npm + + - run: npm ci + + - run: npm test diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..6e08a87 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,95 @@ +name: Release + +on: + push: + branches: [main] + +env: + IMAGE: ${{ vars.REGISTRY_HOST }}/${{ gitea.repository_owner }}/catalyst + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + cache: npm + + - run: npm ci + - run: npm test + + - name: Read version + run: | + VERSION=$(node -p "require('./package.json').version") + echo "VERSION=${VERSION}" >> $GITEA_ENV + + - name: Assert tag does not exist + run: | + if git ls-remote --tags origin "refs/tags/v${{ env.VERSION }}" | grep -q .; then + echo "ERROR: tag v${{ env.VERSION }} already exists — bump version in package.json before merging to main." + exit 1 + fi + + - name: Create and push tag + run: | + git config user.name "gitea-actions" + git config user.email "actions@gitea" + git tag "v${{ env.VERSION }}" + git push origin "v${{ env.VERSION }}" + + - name: Generate release notes + run: | + LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") + if [ -n "$LAST_TAG" ]; then + NOTES=$(git log "${LAST_TAG}..HEAD" --pretty=format:"- %s" --no-merges) + else + NOTES=$(git log --pretty=format:"- %s" --no-merges) + fi + NOTES_JSON=$(printf '%s' "$NOTES" | python3 -c "import sys,json; print(json.dumps(sys.stdin.read()))") + echo "NOTES=${NOTES_JSON}" >> $GITEA_ENV + + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE }} + tags: | + type=semver,pattern={{version}},value=v${{ env.VERSION }} + type=semver,pattern={{major}}.{{minor}},value=v${{ env.VERSION }} + type=sha,prefix=,format=short + type=raw,value=latest + + - name: Log in to registry + uses: docker/login-action@v3 + with: + registry: ${{ vars.REGISTRY_HOST }} + username: ${{ gitea.actor }} + password: ${{ secrets.TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + + - name: Create Gitea release + run: | + curl -sf -X POST \ + -H "Authorization: token ${{ secrets.TOKEN }}" \ + -H "Content-Type: application/json" \ + "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" \ + -d "{ + \"tag_name\": \"v${{ env.VERSION }}\", + \"name\": \"Catalyst v${{ env.VERSION }}\", + \"body\": \"### Changes\n\n${{ env.NOTES }}\n\n### Image\n\n\`${{ env.IMAGE }}:${{ env.VERSION }}\`\", + \"draft\": false, + \"prerelease\": false + }"