From e54b861e728e7f9bd92f9480aad758864da20efe Mon Sep 17 00:00:00 2001 From: etwodev Date: Sun, 5 Oct 2025 03:21:38 +0100 Subject: [PATCH] chore: update releases [ci skip] --- .gitea/workflows/deploy.yml | 124 ++++++++++++++++++++++++++++++++++++ .release-version | 1 + .releaserc.json | 31 +++++++++ 3 files changed, 156 insertions(+) create mode 100644 .gitea/workflows/deploy.yml create mode 100644 .release-version create mode 100644 .releaserc.json diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..e252410 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,124 @@ +name: "Portainer CI/CD Pipeline" + +on: + workflow_call: + inputs: + stack-name: + description: "Name of the Portainer stack to deploy" + required: true + type: string + portainer-url: + description: "Base URL of the Portainer API (e.g. https://portainer.example.com/api)" + required: true + type: string + portainer-endpoint: + description: "Portainer endpoint ID" + required: true + type: string + repo-compose-file: + description: "Path to docker-compose file" + required: false + default: "docker-compose.yml" + type: string + image-name: + description: "Docker image name" + required: true + type: string + registry-url: + description: "Docker registry URL (e.g. ghcr.io)" + required: true + type: string + secrets: + REGISTRY_USERNAME: + description: "Docker registry username" + required: true + REGISTRY_PASSWORD: + description: "Docker registry password" + required: true + CI_GITEA_TOKEN: + description: "Token for version bump and push" + required: true + PORTAINER_TOKEN: + description: "Portainer API token" + required: true + +jobs: + # -------------------------------------------------------- + # Semantic Release (Version bump + changelog) + # -------------------------------------------------------- + release: + name: Semantic Release + runs-on: ubuntu-latest + needs: build + env: + GITEA_TOKEN: ${{ secrets.CI_GITEA_TOKEN }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + token: ${{ secrets.CI_GITEA_TOKEN }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install semantic-release + run: npm install -g semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/exec + + - name: Run semantic-release + run: npx semantic-release + env: + GIT_AUTHOR_NAME: "CI Bot" + GIT_AUTHOR_EMAIL: "ci@etwo.dev" + GIT_COMMITTER_NAME: "CI Bot" + GIT_COMMITTER_EMAIL: "ci@etwo.dev" + IMAGE_NAME: ${{ inputs.image-name }} + + # -------------------------------------------------------- + # Build and Push Docker Image + # -------------------------------------------------------- + build: + name: Build and Push Docker Image + runs-on: ubuntu-latest + env: + IMAGE_NAME: ${{ inputs.image-name }} + REGISTRY_URL: ${{ inputs.registry-url }} + REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Log in to Docker registry + run: | + echo "$REGISTRY_PASSWORD" | docker login $REGISTRY_URL -u "$REGISTRY_USERNAME" --password-stdin + + - name: Build Docker image + run: | + VERSION=$(cat .release-version 2>/dev/null || echo "latest") + echo "Building docker image with tag $VERSION" + docker build -t $REGISTRY_URL/${IMAGE_NAME}:$VERSION . + docker push $REGISTRY_URL/${IMAGE_NAME}:$VERSION + + # -------------------------------------------------------- + # Deploy to Portainer (using your Action) + # -------------------------------------------------------- + deploy: + name: Deploy to Portainer + runs-on: ubuntu-latest + needs: release + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Deploy stack via Portainer API + uses: actions/portable@v1 + with: + portainer-url: ${{ inputs.portainer-url }} + portainer-token: ${{ secrets.PORTAINER_TOKEN }} + portainer-endpoint: ${{ inputs.portainer-endpoint }} + stack-name: ${{ inputs.stack-name }} + repo-url: ${{ github.server_url }}/${{ github.repository }} + repo-ref: ${{ github.ref }} + repo-compose-file: ${{ inputs.repo-compose-file }} diff --git a/.release-version b/.release-version new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/.release-version @@ -0,0 +1 @@ +1.0.0 diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..352975c --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,31 @@ +{ + "branches": [ + "main" + ], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md" + } + ], + [ + "@semantic-release/exec", + { + "prepareCmd": "echo ${nextRelease.version} > .release-version" + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "CHANGELOG.md", + ".release-version" + ], + "message": "chore(release): ${nextRelease.version} [skip ci]" + } + ] + ] +}