From 9504b307a6650b5d14a2e8979c3a2c13453187b6 Mon Sep 17 00:00:00 2001 From: Luca Lanziani Date: Thu, 30 Nov 2023 21:49:30 +0100 Subject: [PATCH] fix: release-please and pipeline templates I was using the wrong output key when building a container. Also we were always pointing generated pipelines to the latest container generated, with this change we will have a container version and we can use that when templating pipelines. --- .github/workflows/release-please.yaml | 4 ++-- assets/github/onbranch.tmpl | 4 ++-- assets/github/onmain.tmpl | 2 +- src/cli/init.go | 8 ++++++++ src/services/project/project.go | 1 + 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index fb44545a..a1c7421e 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -34,7 +34,7 @@ jobs: run: go run main.go build env: INITIUM_APP_NAME: initium-cli - INITIUM_VERSION: ${{ steps.release.outputs.release_tag_name }} + INITIUM_VERSION: ${{ steps.release.outputs.tag_name }} INITIUM_REGISTRY_USER: ${{ github.actor }} INITIUM_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} if: ${{ steps.release.outputs.release_created }} @@ -43,7 +43,7 @@ jobs: run: go run main.go push env: INITIUM_APP_NAME: initium-cli - INITIUM_VERSION: ${{ steps.release.outputs.release_tag_name }} + INITIUM_VERSION: ${{ steps.release.outputs.tag_name }} INITIUM_REGISTRY_USER: ${{ github.actor }} INITIUM_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} if: ${{ steps.release.outputs.release_created }} diff --git a/assets/github/onbranch.tmpl b/assets/github/onbranch.tmpl index 7a62bfa6..5315754d 100644 --- a/assets/github/onbranch.tmpl +++ b/assets/github/onbranch.tmpl @@ -22,7 +22,7 @@ jobs: ref: {{ `${{ github.head_ref }}` }} - name: build and deploy application - uses: docker://ghcr.io/nearform/initium-cli:latest + uses: docker://ghcr.io/nearform/initium-cli:{{ .Version }} with: args: onbranch env: @@ -41,7 +41,7 @@ jobs: - uses: actions/checkout@v3 - name: delete application - uses: docker://ghcr.io/nearform/initium-cli:latest + uses: docker://ghcr.io/nearform/initium-cli:{{ .Version }} with: args: onbranch --clean --branch-name {{ `${{ github.head_ref }}` }} env: diff --git a/assets/github/onmain.tmpl b/assets/github/onmain.tmpl index d747c88d..62fcc12a 100644 --- a/assets/github/onmain.tmpl +++ b/assets/github/onmain.tmpl @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v3 - name: build and deploy on {{ .DefaultBranch }} - uses: docker://ghcr.io/nearform/initium-cli:latest + uses: docker://ghcr.io/nearform/initium-cli:{{ .Version }} with: args: onmain env: diff --git a/src/cli/init.go b/src/cli/init.go index d91bde9a..9a299069 100644 --- a/src/cli/init.go +++ b/src/cli/init.go @@ -25,11 +25,19 @@ func (c icli) InitGithubCMD(cCtx *cli.Context) error { logger := log.New(os.Stderr) logger.SetLevel(log.DebugLevel) + version := "v" + c.release.Version // Go releaser strips the v, we want it back for containers + + if c.release.Version == "dev" { + version = "latest" + } + options := project.InitOptions{ PipelineType: cCtx.Command.Name, DestinationFolder: cCtx.String(destinationFolderFlag), DefaultBranch: cCtx.String(defaultBranchFlag), + Version: version, } + data, err := project.ProjectInit(options, c.Resources) if err != nil { diff --git a/src/services/project/project.go b/src/services/project/project.go index ce42c300..ed621d86 100644 --- a/src/services/project/project.go +++ b/src/services/project/project.go @@ -35,6 +35,7 @@ type InitOptions struct { DestinationFolder string DefaultBranch string PipelineType string + Version string } func GuessAppName() *string {