diff --git a/.github/workflows/creating_pr.yml b/.github/workflows/creating_pr.yml new file mode 100644 index 0000000..1b88b2f --- /dev/null +++ b/.github/workflows/creating_pr.yml @@ -0,0 +1,42 @@ +name: Prepare Release PR + +on: + workflow_dispatch: + inputs: + tag: + description: 'Tag to release' + required: true + +jobs: + create-release-pr: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.github.com" + + - name: Update Chart and Values Versions + run: | + sed -i "s/^version:.*/version: ${{ github.event.inputs.tag }}/" Chart.yaml + sed -i "s/^appVersion:.*/appVersion: '${{ github.event.inputs.tag }}'/" Chart.yaml + sed -i "s/^version:.*/version: ${{ github.event.inputs.tag }}/" values.yaml + + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + commit-message: "chore(release): update to ${{ github.event.inputs.tag }}" + branch: release/${{ github.event.inputs.tag }} + base: main + title: "Release ${{ github.event.inputs.tag }}" + body: "This PR updates the chart versions to ${{ github.event.inputs.tag }}." + labels: release + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + signoff: true + update-existing-pr: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ad5748..73ce11c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,17 +1,14 @@ -name: Release Charts +name: Release Charts on Merge on: - workflow_dispatch: - inputs: - tag: - description: 'Tag to release' - required: true - default: '1.0.0' + pull_request: + types: [closed] + branches: + - main jobs: - release: - permissions: - contents: write + release-on-merge: + if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - name: Checkout @@ -21,27 +18,65 @@ jobs: - name: Configure Git run: | - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + git config user.name "${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.github.com" + + - name: Installer jq + run: sudo apt-get install jq + + - name: Check 'release' Label + id: check_release_label + run: | + labels='${{ toJSON(github.event.pull_request.labels) }}' + echo "Labels de la PR : $labels" + if echo "$labels" | jq -e '.[] | select(.name=="release")' > /dev/null; then + echo "has_release_label=true" >> $GITHUB_ENV + else + echo "has_release_label=false" >> $GITHUB_ENV + fi - name: Lint Chart - Main chart - run: helm lint . + if: env.has_release_label == 'true' + run: helm lint . - name: Update Dependencies - run: helm dependency update . - - - name: Run chart-releaser - uses: helm/chart-releaser-action@v1.6.0 - with: - charts_dir: "." - config: cr.yaml - env: - CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + if: env.has_release_label == 'true' + run: helm dependency update . - name: Deploy to GitHub Pages + if: env.has_release_label == 'true' run: | git checkout gh-pages - helm repo index . --url https://getlago.github.io/lago-helm-charts + git pull origin main --rebase + helm package . --destination charts/ + helm repo index . --url https://getlago.github.io/charts git add . - git commit -m "Update Helm repo index for tag ${{ github.event.inputs.tag }}" + git add charts/ + git commit -m "Update Helm repo index after release" git push origin gh-pages + + - name: Extract version from Chart.yaml + if: env.has_release_label == 'true' + id: get_version + run: | + version=$(grep '^version:' Chart.yaml | awk '{print $2}') + echo "Extracted version: $version" + echo "version=$version" >> $GITHUB_ENV + + - name: Create Git tag + if: env.has_release_label == 'true' + run: | + git tag "v${{ env.version }}" + git push origin "v${{ env.version }}" + + - name: Create GitHub Release + if: env.has_release_label == 'true' + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: "v${{ env.version }}" + release_name: "Release v${{ env.version }}" + body: "Release of version v${{ env.version }}" + draft: false + prerelease: false diff --git a/.gitignore b/.gitignore index 2ed7a44..90001b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ Chart.lock -charts/*.tgz diff --git a/Chart.yaml b/Chart.yaml index 164703b..e8fff31 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 -appVersion: '1.12.3' +appVersion: '1.14.0' description: the Lago open source billing app name: lago -version: 1.12.3 +version: 1.14.0 dependencies: - name: postgresql version: '13.2.2' diff --git a/templates/events-worker-deployment.yaml b/templates/events-worker-deployment.yaml index ffb1546..87d203a 100644 --- a/templates/events-worker-deployment.yaml +++ b/templates/events-worker-deployment.yaml @@ -116,5 +116,9 @@ spec: livenessProbe: exec: command: ["/bin/bash", "-l", "-c", "bundle exec sidekiqmon processes | grep $(hostname) || exit 1"] + initialDelaySeconds: {{ .Values.eventsWorker.livenessProbe.initialDelaySeconds | default 0 }} + periodSeconds: {{ .Values.eventsWorker.livenessProbe.periodSeconds | default 10 }} + timeoutSeconds: {{ .Values.eventsWorker.livenessProbe.timeoutSeconds | default 1 }} + failureThreshold: {{ .Values.eventsWorker.livenessProbe.failureThreshold | default 3 }} restartPolicy: Always serviceAccountName: {{ .Values.global.serviceAccountName | default (printf "%s-serviceaccount" .Release.Name) }} diff --git a/templates/worker-deployment.yaml b/templates/worker-deployment.yaml index d7d401b..71cfaa1 100644 --- a/templates/worker-deployment.yaml +++ b/templates/worker-deployment.yaml @@ -116,32 +116,69 @@ spec: name: {{ .Release.Name }}-secrets key: license {{ end }} - {{ if .Values.global.s3.enabled }} + + {{ if or .Values.global.s3.enabled .Values.minio.enabled }} - name: LAGO_USE_AWS_S3 value: "true" - {{ if .Values.global.s3.endpoint }} + {{- if .Values.minio.enabled }} + - name: LAGO_AWS_S3_PATH_STYLE + value: "true" + {{- end }} + {{ if or .Values.global.s3.endpoint .Values.minio.endpoint }} - name: LAGO_AWS_S3_ENDPOINT - value: {{ .Values.global.s3.endpoint | quote }} + value: {{ if .Values.minio.enabled }} + {{ .Values.minio.endpoint | quote }} + {{ else }} + {{ .Values.global.s3.endpoint | quote }} + {{ end }} {{ end }} - {{ if or .Values.global.s3.accessKeyId .Values.global.existingSecret }} + + {{ if or .Values.global.s3.accessKeyId .Values.minio.enabled .Values.global.existingSecret }} - name: LAGO_AWS_S3_ACCESS_KEY_ID valueFrom: secretKeyRef: - name: {{ include "secret-path" . }} - key: awsS3AccessKeyId + name: {{ if .Values.minio.enabled }} + {{ .Release.Name }}-minio + {{ else }} + {{ include "secret-path" . }} + {{ end }} + key: {{ if .Values.minio.enabled }} + rootUser + {{ else }} + awsS3AccessKeyId + {{ end }} {{ end }} - {{ if or .Values.global.s3.secretAccessKey .Values.global.existingSecret }} + + {{ if or .Values.global.s3.secretAccessKey .Values.minio.enabled .Values.global.existingSecret }} - name: LAGO_AWS_S3_SECRET_ACCESS_KEY valueFrom: secretKeyRef: - name: {{ include "secret-path" . }} - key: awsS3SecretAccessKey + name: {{ if .Values.minio.enabled }} + {{ .Release.Name }}-minio + {{ else }} + {{ include "secret-path" . }} + {{ end }} + key: {{ if .Values.minio.enabled }} + rootPassword + {{ else }} + awsS3SecretAccessKey + {{ end }} {{ end }} + - name: LAGO_AWS_S3_BUCKET - value: {{ .Values.global.s3.bucket | quote }} + value: {{ if .Values.minio.enabled }} + {{ (index .Values.minio.buckets 0).name | quote }} + {{ else }} + {{ .Values.global.s3.bucket | quote }} + {{ end }} - name: LAGO_AWS_S3_REGION - value: {{ .Values.global.s3.region | quote }} + value: {{ if .Values.global.s3.enabled }} + {{ .Values.global.s3.region | quote }} + {{ else if .Values.minio.enabled }} + {{ default "us-east-1" .Values.minio.region | quote }} + {{ end }} {{ end }} + {{ if .Values.global.smtp.enabled }} - name: LAGO_FROM_EMAIL value: {{ .Values.global.smtp.fromEmail }} @@ -172,17 +209,21 @@ spec: livenessProbe: exec: command: ["/bin/bash", "-l", "-c", "bundle exec sidekiqmon processes | grep $(hostname) || exit 1"] + initialDelaySeconds: {{ .Values.worker.livenessProbe.initialDelaySeconds | default 0 }} + periodSeconds: {{ .Values.worker.livenessProbe.periodSeconds | default 10 }} + timeoutSeconds: {{ .Values.worker.livenessProbe.timeoutSeconds | default 1 }} + failureThreshold: {{ .Values.worker.livenessProbe.failureThreshold | default 3 }} {{- with .Values.worker.resources }} resources: {{- toYaml . | nindent 12}} {{- end }} - {{ if not .Values.global.s3.enabled }} + {{ if and (not .Values.global.s3.enabled) (not .Values.minio.enabled) }} volumeMounts: - mountPath: /app/storage name: {{ .Release.Name }}-storage-data {{ end }} restartPolicy: Always - {{ if not .Values.global.s3.enabled }} + {{ if and (not .Values.global.s3.enabled) (not .Values.minio.enabled) }} volumes: - name: {{ .Release.Name }}-storage-data persistentVolumeClaim: diff --git a/values.yaml b/values.yaml index b72c670..406a894 100644 --- a/values.yaml +++ b/values.yaml @@ -1,4 +1,4 @@ -version: '1.12.3' +version: 1.14.0 # apiUrl: mydomain.dev # frontUrl: mydomain.dev @@ -143,6 +143,11 @@ worker: podAnnotations: {} podLabels: {} extraEnv: {} + livenessProbe: + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 eventsWorker: replicas: 1 @@ -158,6 +163,11 @@ eventsWorker: podAnnotations: {} podLabels: {} extraEnv: {} + livenessProbe: + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 clock: