From 58460d988d39448bf6d5554b282b527fc12b16df Mon Sep 17 00:00:00 2001 From: sherl Date: Tue, 9 Dec 2025 12:32:38 +0100 Subject: [PATCH] chore: add new workflows (changelog, automatic releases) Docker images will now be built on every release --- .../workflows/{docker.yaml => 01_docker.yaml} | 17 +++++---- .gitea/workflows/02_release.yaml | 34 +++++++++++++++++ .gitea/workflows/99_changelog.yaml | 37 +++++++++++++++++++ 3 files changed, 81 insertions(+), 7 deletions(-) rename .gitea/workflows/{docker.yaml => 01_docker.yaml} (68%) create mode 100644 .gitea/workflows/02_release.yaml create mode 100644 .gitea/workflows/99_changelog.yaml diff --git a/.gitea/workflows/docker.yaml b/.gitea/workflows/01_docker.yaml similarity index 68% rename from .gitea/workflows/docker.yaml rename to .gitea/workflows/01_docker.yaml index 7e2b669..a2d8f54 100644 --- a/.gitea/workflows/docker.yaml +++ b/.gitea/workflows/01_docker.yaml @@ -2,11 +2,12 @@ # https://gitea.com/gitea/runner-images/src/branch/main/.gitea/workflows/release.yaml name: Build and push Docker image -run-name: Building image on ${{ gitea.actor }}'s commit +run-name: Build ${{ github.ref_name }} image on: push: - branches: [ master ] + tags: + - "*" jobs: build: @@ -34,8 +35,9 @@ jobs: env: BRANCH_NAME: ${{ github.ref_name }} run: | - echo branch_name="$BRANCH_NAME" | tee -a $GITHUB_OUTPUT - echo short_hash=$(git rev-parse --short HEAD) | tee -a $GITHUB_OUTPUT + #echo branch_name="$BRANCH_NAME" | tee -a $GITHUB_OUTPUT + #echo short_hash=$(git rev-parse --short HEAD) | tee -a $GITHUB_OUTPUT + echo current_tag=$GITHUB_REF_NAME | tee -a $GITHUB_OUTPUT - name: Build and push uses: docker/build-push-action@v6 @@ -46,10 +48,11 @@ jobs: linux/arm64 pull: true push: true + # Change when working on a different branch! tags: | - gitea.7o7.cx/kittyteam/kittybe:${{ steps.vars.outputs.branch_name }}-${{ steps.vars.outputs.short_hash }} - gitea.7o7.cx/kittyteam/kittybe:${{ steps.vars.outputs.branch_name }}-latest + gitea.7o7.cx/kittyteam/kittybe:master-${{ steps.vars.outputs.current_tag }} + gitea.7o7.cx/kittyteam/kittybe:latest - name: Log out from registry if: always() - run: docker logout gitea.7o7.cx \ No newline at end of file + run: docker logout gitea.7o7.cx diff --git a/.gitea/workflows/02_release.yaml b/.gitea/workflows/02_release.yaml new file mode 100644 index 0000000..76503f3 --- /dev/null +++ b/.gitea/workflows/02_release.yaml @@ -0,0 +1,34 @@ +# Credits: # https://gitea.com/gitea/runner-images/src/branch/main/.gitea/workflows/release.yaml +name: Release new version +run-name: Release ${{ github.ref_name }} + +on: + push: + tags: + - "*" + +jobs: + release: + runs-on: ubuntu-latest + container: docker.io/thegeeklab/git-sv:2.0.9 + steps: + - name: install tools + run: | + apk add -q --update --no-cache nodejs + - uses: actions/checkout@v6 + with: + fetch-tags: true + fetch-depth: 0 + + - name: Create changelog + run: | + git sv current-version + git sv release-notes -t ${GITHUB_REF#refs/tags/} -o CHANGELOG.md + sed -i '1,2d' CHANGELOG.md # remove version + cat CHANGELOG.md + + - name: Release + uses: https://github.com/akkuman/gitea-release-action@v1 + with: + body_path: CHANGELOG.md + token: "${{ secrets.REPO_RW_TOKEN }}" diff --git a/.gitea/workflows/99_changelog.yaml b/.gitea/workflows/99_changelog.yaml new file mode 100644 index 0000000..b9c63bb --- /dev/null +++ b/.gitea/workflows/99_changelog.yaml @@ -0,0 +1,37 @@ +# Credit: https://gitea.com/gitea/helm-gitea/src/branch/main/.gitea/workflows/changelog.yml +name: Update changelog +run-name: Update changelog on push + +on: + push: + branches: + - master + tags: + - "*" + +jobs: + changelog: + runs-on: ubuntu-latest + container: docker.io/thegeeklab/git-sv:2.0.9 + steps: + - name: Install tools + run: | + apk add -q --update --no-cache nodejs curl jq sed + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Generate upcoming changelog + run: | + git sv rn -o changelog.md + export RELEASE_NOTES=$(cat changelog.md) + export ISSUE_NUMBER=$(curl -s -H 'Authorization: token ${{ secrets.ISSUE_RW_TOKEN }}' "https://gitea.7o7.cx/api/v1/repos/kittyteam/kittyBE/issues?state=open&q=Changelog%20for%20upcoming%20version" | jq '.[].number') + + echo $RELEASE_NOTES + JSON_DATA=$(echo "" | jq -Rs --arg title 'Changelog for upcoming version' --arg body "$(cat changelog.md)" '{title: $title, body: $body}') + + if [ -z "$ISSUE_NUMBER" ]; then + curl -s -X POST "https://gitea.7o7.cx/api/v1/repos/kittyteam/kittyBE/issues" -H "Authorization: token ${{ secrets.ISSUE_RW_TOKEN }}" -H "Content-Type: application/json" -d "$JSON_DATA" > /dev/null + else + curl -s -X PATCH "https://gitea.7o7.cx/api/v1/repos/kittyteam/kittyBE/issues/$ISSUE_NUMBER" -H "Authorization: token ${{ secrets.ISSUE_RW_TOKEN }}" -H "Content-Type: application/json" -d "$JSON_DATA" > /dev/null + fi