From 0324a148d3b7c1df47cadf8345dd42dd20906914 Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Thu, 14 Nov 2024 14:14:07 +1100 Subject: [PATCH 1/5] feat: Use release-please --- .github/workflows/release-please.yaml | 31 +++++++++++++++++++++++++++ release-please-config.json | 13 +++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/workflows/release-please.yaml create mode 100644 release-please-config.json diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml new file mode 100644 index 0000000..6f5f697 --- /dev/null +++ b/.github/workflows/release-please.yaml @@ -0,0 +1,31 @@ +name: Release Please +on: + push: + branches: + - main + +permissions: + actions: read # Read the metrics + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + id-token: write # to enable use of OIDC for npm provenance / AWS + +env: + MISE_PYTHON_COMPILE: false + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + release_gitops_cli: + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@v4 + id: release + # Configured via: release-please-config.json and will update the manifest: .release-please-manifest.json + with: {} + outputs: + # Root level release_created + release_created: ${{ steps.release.outputs.release_created }} + # Root level tag_name + tag_name: ${{ steps.release.outputs.tag_name }} + sha: ${{ steps.release.outputs.sha }} diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..fd66d64 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,13 @@ +{ + "packages": { + ".": { + "package-name": "gitops", + "release-type": "python", + "exclude-paths": [ + "tests/", + "charts/", + "gitops_server/" + ] + } + } +} From b7b669633c094cafbdd33fbf63981dab53c0456a Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Thu, 14 Nov 2024 14:30:37 +1100 Subject: [PATCH 2/5] chore: Use Fix branch name --- .github/workflows/release-please.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index 6f5f697..4b6ed50 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -2,7 +2,7 @@ name: Release Please on: push: branches: - - main + - develop permissions: actions: read # Read the metrics From 1d23e7a78bddc04d24030292bcea0c2cd139bd72 Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Thu, 14 Nov 2024 14:53:38 +1100 Subject: [PATCH 3/5] chore: Adding an initial release-please manifest, configuring separate releases for CLI,Server and Chart --- .release-please-manifest.json | 5 +++++ release-please-config.json | 17 ++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 .release-please-manifest.json diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..2997a5a --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,5 @@ +{ + "gitops": "0.12.1", + "gitops_server": "0.12.1", + "charts/gitops": "0.12.1" +} diff --git a/release-please-config.json b/release-please-config.json index fd66d64..a71ef95 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1,13 +1,16 @@ { "packages": { - ".": { + "gitops": { "package-name": "gitops", - "release-type": "python", - "exclude-paths": [ - "tests/", - "charts/", - "gitops_server/" - ] + "release-type": "python" + }, + "gitops_server": { + "package-name": "gitops-server", + "release-type": "python" + }, + "charts/gitops":{ + "package-name": "gitops-chart", + "release-type": "helm" } } } From 132790b6853bb328b32a4658d9c89743ca1907af Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Thu, 14 Nov 2024 16:38:44 +1100 Subject: [PATCH 4/5] chore: Adding more complex release-please config --- .github/workflows/release-please.yaml | 65 +++++++++++++++++++++++---- CHANGELOG.md | 0 charts/gitops/CHANGELOG.md | 0 gitops_server/CHANGELOG.md | 0 release-please-config.json | 32 +++++++++---- 5 files changed, 79 insertions(+), 18 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 charts/gitops/CHANGELOG.md create mode 100644 gitops_server/CHANGELOG.md diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index 4b6ed50..de59173 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -16,16 +16,63 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - release_gitops_cli: + release-please: runs-on: ubuntu-latest + outputs: + cli-release-created: ${{ steps.release.outputs['.--release_created'] }} + server-release-created: ${{ steps.release.outputs['gitops_server--release_created'] }} + helm-release-created: ${{ steps.release.outputs['charts/gitops--release_created'] }} + cli-version: ${{ steps.release.outputs['.--tag_name'] }} + server-version: ${{ steps.release.outputs['gitops_server--tag_name'] }} + helm-version: ${{ steps.release.outputs['charts/gitops--tag_name'] }} + sha: ${{ steps.release.outputs.sha }} steps: - - uses: googleapis/release-please-action@v4 + - uses: google-github-actions/release-please-action@v4 id: release - # Configured via: release-please-config.json and will update the manifest: .release-please-manifest.json with: {} - outputs: - # Root level release_created - release_created: ${{ steps.release.outputs.release_created }} - # Root level tag_name - tag_name: ${{ steps.release.outputs.tag_name }} - sha: ${{ steps.release.outputs.sha }} + publish_helm_chart: + runs-on: ubuntu-latest + needs: release-please + steps: + - uses: actions/checkout@v3 + - name: Publish Helm charts + uses: stefanprodan/helm-gh-pages@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + app_version: "${{ needs.release-please.outputs.server-version }}" + chart_version: "${{ needs.release-please.outputs.helm-version }}" + publish_to_pypi: + name: Publishes tag to pypi + runs-on: ubuntu-latest + needs: release-please + steps: + - uses: actions/checkout@v3 + + - uses: jdx/mise-action@v2 + with: + install: true + cache: true + experimental: true + + - run: | + mise run build + shell: bash + + - name: Publish Pypi Package + uses: pypa/gh-action-pypi-publish@release/v1 + publish_docker_image: + name: Build and Push Docker Image + uses: uptick/actions/.github/workflows/ci.yaml@main + needs: release-please + secrets: + SECRET_ENV: "${{ secrets.CLUSTER_KEY }}" + #https://github.com/uptick/actions/blob/main/.github/workflows/ci.yaml + with: + aws-iam-role-arn: "arn:aws:iam::305686791668:role/default-github-actions-ci-role" + docker-enabled: true + docker-context: "." + docker-tag: "${{ needs.release-please.outputs.server-version }}" + docker-tag-latest: true + docker-image-platforms: linux/amd64 + docker-repository: "305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/gitops" + command: echo $SECRET_ENV | base64 -d > cluster.key diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/charts/gitops/CHANGELOG.md b/charts/gitops/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/gitops_server/CHANGELOG.md b/gitops_server/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/release-please-config.json b/release-please-config.json index a71ef95..06c6002 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1,16 +1,30 @@ { "packages": { - "gitops": { - "package-name": "gitops", - "release-type": "python" + ".": { + "package-name": "cli", + "release-type": "python", + "changelog-path": "CHANGELOG.md", + "exclude-paths": [ + "tests/", + "charts/gitops", + "gitops_server/" + ] }, "gitops_server": { - "package-name": "gitops-server", - "release-type": "python" + "package-name": "server", + "release-type": "python", + "changelog-path": "gitops_server/CHANGELOG.md", + "extra-files": [ + { + "type": "helm", + "path": "charts/gitops/chart.yaml" + } + ] }, - "charts/gitops":{ - "package-name": "gitops-chart", - "release-type": "helm" + "charts/gitops": { + "package-name": "helm", + "release-type": "helm", + "changelog-path": "charts/gitops/CHANGELOG.md" } } -} +} \ No newline at end of file From 94e1fa5cc22ea7047e0bc31690807d33470c6b7a Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Thu, 14 Nov 2024 17:53:06 +1100 Subject: [PATCH 5/5] chore: Control publishing steps with conditions according to outputs --- .github/workflows/release-please.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index de59173..ff87b99 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -33,6 +33,7 @@ jobs: publish_helm_chart: runs-on: ubuntu-latest needs: release-please + if: ${{ needs.release-please.outputs.server-version }} || ${{ needs.release-please.outputs.helm-version }} steps: - uses: actions/checkout@v3 - name: Publish Helm charts @@ -45,6 +46,7 @@ jobs: name: Publishes tag to pypi runs-on: ubuntu-latest needs: release-please + if: ${{ needs.release-please.outputs.cli-version }} steps: - uses: actions/checkout@v3 @@ -64,6 +66,7 @@ jobs: name: Build and Push Docker Image uses: uptick/actions/.github/workflows/ci.yaml@main needs: release-please + if: ${{ needs.release-please.outputs.server-version }} secrets: SECRET_ENV: "${{ secrets.CLUSTER_KEY }}" #https://github.com/uptick/actions/blob/main/.github/workflows/ci.yaml