Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/bump-network-launcher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Bump network-launcher

on:
workflow_dispatch:
inputs:
version:
description: 'icp-cli-network-launcher release version (e.g. v12.0.0-2026-04-16-04-20 or 12.0.0-2026-04-16-04-20)'
required: true

jobs:
bump-network-launcher:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Verify release tag exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ inputs.version }}"
TAG="v${VERSION#v}"
if ! gh release view "$TAG" --repo dfinity/icp-cli-network-launcher >/dev/null 2>&1; then
echo "::error::Release tag '$TAG' not found in dfinity/icp-cli-network-launcher"
exit 1
fi

- name: Update network-launcher-version
id: update
run: |
VERSION="${{ inputs.version }}"
VERSION="${VERSION#v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
printf '%s' "$VERSION" > network-launcher-version
Comment thread
lwshang marked this conversation as resolved.

if git diff --quiet; then
echo "needs_update=false" >> "$GITHUB_OUTPUT"
else
echo "needs_update=true" >> "$GITHUB_OUTPUT"
fi

- name: Create GitHub App Token
if: steps.update.outputs.needs_update == 'true'
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: app-token
with:
client-id: ${{ vars.PR_AUTOMATION_BOT_PUBLIC_CLIENT_ID }}
private-key: ${{ secrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEY }}

- name: Open pull request
if: steps.update.outputs.needs_update == 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
APP_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
VERSION="${{ steps.update.outputs.version }}"
BRANCH="chore/bump-network-launcher-${VERSION}"
TITLE="chore(deps): bump network-launcher to ${VERSION}"
BODY="Updates \`network-launcher-version\` to \`${VERSION}\`."

git config user.name "pr-automation-bot-public[bot]"
git config user.email "pr-automation-bot-public[bot]@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${APP_TOKEN}@github.com/${{ github.repository }}.git"
git checkout -b "$BRANCH"
git add network-launcher-version
git commit -m "$TITLE"
Comment thread
lwshang marked this conversation as resolved.
git push origin "$BRANCH" --force

existing=$(gh pr list --head "$BRANCH" --base main --state open --json number --jq 'length')
if [[ "$existing" == "0" ]]; then
gh pr create --title "$TITLE" --body "$BODY" --base main --head "$BRANCH"
else
echo "PR already open on $BRANCH, branch updated."
fi
40 changes: 40 additions & 0 deletions .github/workflows/promote-network-launcher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Promote network-launcher

on:
push:
branches: [main]
paths:
- network-launcher-version

jobs:
promote-network-launcher:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Read version
id: ver
run: |
VERSION=$(tr -d '[:space:]' < network-launcher-version)
if [[ -z "$VERSION" ]]; then
echo "::error::network-launcher-version is empty"
exit 1
fi
echo "tag=v${VERSION#v}" >> "$GITHUB_OUTPUT"

- name: Create GitHub App Token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: app-token
with:
client-id: ${{ vars.PR_AUTOMATION_BOT_PUBLIC_CLIENT_ID }}
private-key: ${{ secrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEY }}
owner: dfinity
repositories: icp-cli-network-launcher

- name: Dispatch promote-release workflow
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh workflow run promote-release.yml \
--repo dfinity/icp-cli-network-launcher \
-f tag="${{ steps.ver.outputs.tag }}"
9 changes: 6 additions & 3 deletions crates/icp-cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ fn define_git_sha() {
}

fn define_test_network_launcher_version() {
let raw = std::fs::read_to_string("test-network-launcher-version")
.expect("missing test-network-launcher-version file");
let path = concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../network-launcher-version"
);
let raw = std::fs::read_to_string(path).expect("missing network-launcher-version file");
let version = raw.trim().trim_start_matches('v');
println!("cargo:rustc-env=TEST_NETWORK_LAUNCHER_VERSION={version}");
println!("cargo:rerun-if-changed=test-network-launcher-version");
println!("cargo:rerun-if-changed=../../network-launcher-version");

let out_dir = std::env::var("OUT_DIR").unwrap();

Expand Down
2 changes: 1 addition & 1 deletion crates/icp-cli/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(crate) const PATH_SEPARATOR: &str = ":";
pub(crate) const PATH_SEPARATOR: &str = ";";

// NETWORK_RANDOM_PORT, NETWORK_DOCKER, NETWORK_DOCKER_ENGINE are generated by build.rs
// with the version from test-network-launcher-version injected.
// with the version from network-launcher-version injected.
include!(concat!(env!("OUT_DIR"), "/network_constants.rs"));

/// An environment manifest utilizing the above network
Expand Down
2 changes: 1 addition & 1 deletion scripts/download_test_network_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

VERSION_FILE="$WORKSPACE_ROOT/crates/icp-cli/test-network-launcher-version"
VERSION_FILE="$WORKSPACE_ROOT/network-launcher-version"
TARGET_DIR="$WORKSPACE_ROOT/target/test-fixture"
VERSION_CACHE="$TARGET_DIR/network-launcher-version"

Expand Down
Loading