From 657ff01e7b3b27eaf1877b61b5768a4df95c2714 Mon Sep 17 00:00:00 2001 From: Lionello Lunesu Date: Thu, 9 Apr 2026 16:09:00 -0700 Subject: [PATCH 1/5] feat:support Git ref in cli-version --- .github/workflows/test.yaml | 7 +++++++ README.md | 18 ++++++++++++++++-- action.yaml | 21 ++++++++++++++++++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 29cb8bc..1f29edc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -42,6 +42,13 @@ jobs: DEFANG_GH_ACTION_TEST_ENV: "foo" DEFANG_GH_ACTION_TEST_MESSAGE: ${{ secrets.MESSAGE }} + - name: Deploy from Git ref + uses: ./ + with: + cli-version: main + cwd: "./test" + command: "config help" + - name: Deploy-Empty-Params uses: ./ continue-on-error: true # Ignore dry run error diff --git a/README.md b/README.md index e5b1090..6ff1d51 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,21 @@ jobs: - name: Deploy uses: DefangLabs/defang-github-action@v2 with: - cli-version: v2.10.0 + cli-version: v3.5.2 +``` + +You can also pass any Git ref (branch name or commit SHA) to build the CLI from source: + +```yaml +jobs: + test: + # [...] + steps: + # [...] + - name: Deploy + uses: DefangLabs/defang-github-action@v2 + with: + cli-version: main ``` ### Customizing the Defang Command @@ -134,7 +148,7 @@ jobs: - name: Deploy uses: DefangLabs/defang-github-action@v2 with: - cli-version: v2.10.0 + cli-version: v3.5.2 config-env-vars: "API_KEY DB_CONNECTION_STRING" cwd: "./test" compose-files: "./docker-compose.yaml" diff --git a/action.yaml b/action.yaml index a62b1eb..b81da8f 100644 --- a/action.yaml +++ b/action.yaml @@ -7,7 +7,7 @@ branding: inputs: cli-version: - description: "The version of the Defang CLI to use. Defaults to the latest stable release." + description: "The version or Git ref of the Defang CLI to use. Defaults to the latest stable release." required: false default: "" config-env-vars: @@ -63,6 +63,25 @@ outputs: runs: using: "composite" steps: + - name: Checkout CLI repository + if: inputs.cli-version != '' && inputs.cli-version != 'nightly' && !contains(inputs.cli-version, '.') + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: DefangLabs/defang + ref: ${{ inputs.cli-version }} + path: defang-cli + + - name: Setup Go + if: inputs.cli-version != '' && inputs.cli-version != 'nightly' && !contains(inputs.cli-version, '.') + uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 + with: + go-version-file: defang-cli/src/go.mod + + - name: Build CLI from source + if: inputs.cli-version != '' && inputs.cli-version != 'nightly' && !contains(inputs.cli-version, '.') + shell: bash + run: cd defang-cli/src && go build -o "$RUNNER_TOOL_CACHE/defang" ./cmd/cli && echo "$RUNNER_TOOL_CACHE" >> "$GITHUB_PATH" + - name: Install defang shell: bash run: | From 4be51872731c05a13f8f442b382e007c8b7fd94a Mon Sep 17 00:00:00 2001 From: Lionello Lunesu Date: Thu, 9 Apr 2026 16:29:56 -0700 Subject: [PATCH 2/5] chore: clarify if condition --- action.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index b81da8f..f71413e 100644 --- a/action.yaml +++ b/action.yaml @@ -63,7 +63,10 @@ outputs: runs: using: "composite" steps: + # If cli-version is a Git ref (not empty, not "nightly", and no dots, eg. no "v1.2.3"), + # build the CLI from source instead of downloading a release. - name: Checkout CLI repository + id: checkout-cli if: inputs.cli-version != '' && inputs.cli-version != 'nightly' && !contains(inputs.cli-version, '.') uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -72,13 +75,13 @@ runs: path: defang-cli - name: Setup Go - if: inputs.cli-version != '' && inputs.cli-version != 'nightly' && !contains(inputs.cli-version, '.') + if: steps.checkout-cli.outcome == 'success' uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 with: go-version-file: defang-cli/src/go.mod - name: Build CLI from source - if: inputs.cli-version != '' && inputs.cli-version != 'nightly' && !contains(inputs.cli-version, '.') + if: steps.checkout-cli.outcome == 'success' shell: bash run: cd defang-cli/src && go build -o "$RUNNER_TOOL_CACHE/defang" ./cmd/cli && echo "$RUNNER_TOOL_CACHE" >> "$GITHUB_PATH" From 9d43a7967b561a9734fc4db43a08c45b918ad051 Mon Sep 17 00:00:00 2001 From: Lionello Lunesu Date: Thu, 9 Apr 2026 16:33:11 -0700 Subject: [PATCH 3/5] docs: enhance CLI version specification details in README --- README.md | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6ff1d51..5eac2a6 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,10 @@ jobs: ### Specifying the CLI Version -If you want to use a specific version of the Defang CLI, you can specify it using the `cli-version` input. Specify a version number, or `nightly` to use the nightly CLI build. Note that the nightly builds have only undergone limited automated testing and should be considered unstable. +If you want to use a specific version of the Defang CLI, you can specify it using the `cli-version` input. +Specify a version number (with or without `v`), or `nightly` to use the nightly CLI build. +Note that the nightly builds have only undergone limited automated testing and should be considered unstable. +You can also pass any Git ref (branch name like `main` or commit SHA) to build the CLI from source using `go`. ```yaml jobs: @@ -88,21 +91,7 @@ jobs: - name: Deploy uses: DefangLabs/defang-github-action@v2 with: - cli-version: v3.5.2 -``` - -You can also pass any Git ref (branch name or commit SHA) to build the CLI from source: - -```yaml -jobs: - test: - # [...] - steps: - # [...] - - name: Deploy - uses: DefangLabs/defang-github-action@v2 - with: - cli-version: main + cli-version: v3.5.2 # or 3.5.2 or nightly or main or a commit SHA ``` ### Customizing the Defang Command From 0344303f9ba07f03b3507188ce27278bb00ed17c Mon Sep 17 00:00:00 2001 From: Lionello Lunesu Date: Thu, 9 Apr 2026 16:35:51 -0700 Subject: [PATCH 4/5] chore: remove wildcard branch triggers from workflow --- .github/workflows/test.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1f29edc..030481c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,10 +4,7 @@ on: push: branches: - main - - "**" pull_request: - branches: - - "**" workflow_dispatch: # schedule: # - cron: "0 0 * * *" # daily at midnight From 9dd47344a9db6960e3120b3ae95b5ca0385f2cf1 Mon Sep 17 00:00:00 2001 From: Lionello Lunesu Date: Thu, 9 Apr 2026 16:38:36 -0700 Subject: [PATCH 5/5] chore: add cache-dependency-path for Go setup in action.yaml --- action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yaml b/action.yaml index f71413e..38c586f 100644 --- a/action.yaml +++ b/action.yaml @@ -79,6 +79,7 @@ runs: uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 with: go-version-file: defang-cli/src/go.mod + cache-dependency-path: defang-cli/src/go.sum - name: Build CLI from source if: steps.checkout-cli.outcome == 'success'