@@ -3,6 +3,11 @@ name: publish
33
44on :
55 workflow_dispatch :
6+ inputs :
7+ stellar_cli_version :
8+ description : stellar-cli version to publish (must be declared in builds.json, e.g. 26.0.0)
9+ required : true
10+ type : string
611 push :
712 tags :
813 - v*
@@ -19,16 +24,30 @@ jobs:
1924 runs-on : ubuntu-24.04
2025 outputs :
2126 matrix : ${{ steps.resolve.outputs.matrix }}
27+ stellar_cli_version : ${{ steps.scope.outputs.version }}
2228 steps :
2329 - name : checkout
2430 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2531 - name : install check-jsonschema
2632 run : pipx install check-jsonschema
2733 - name : validate builds.json
2834 run : ./scripts/validate-json.sh
35+ - name : scope to one cli version
36+ id : scope
37+ run : |
38+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
39+ version="${{ inputs.stellar_cli_version }}"
40+ else
41+ tag="${GITHUB_REF#refs/tags/}"
42+ version="${tag#v}"
43+ fi
44+ echo "version=$version" >> "$GITHUB_OUTPUT"
2945 - name : resolve matrix
3046 id : resolve
31- run : echo "matrix=$(./scripts/resolve-matrix.sh)" >> "$GITHUB_OUTPUT"
47+ run : |
48+ matrix="$(./scripts/resolve-matrix.sh \
49+ --stellar-cli-version "${{ steps.scope.outputs.version }}")"
50+ echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
3251
3352 build :
3453 name : ${{ matrix.stellar_cli_version }} rust${{ matrix.rust_version }} ${{ matrix.arch }}
@@ -93,8 +112,10 @@ jobs:
93112
94113 manifest :
95114 name : assemble manifest lists
96- needs : build
115+ needs : [matrix, build]
97116 runs-on : ubuntu-24.04
117+ env :
118+ STELLAR_CLI_VERSION : ${{ needs.matrix.outputs.stellar_cli_version }}
98119 steps :
99120 - name : checkout
100121 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -107,16 +128,14 @@ jobs:
107128 password : ${{ secrets.DOCKERHUB_TOKEN }}
108129 - name : create manifest list per (cli, rust) pair
109130 run : |
110- while IFS= read -r row; do
111- cli="$(jq -r '.cli' <<<"$row")"
112- rust="$(jq -r '.rust' <<<"$row")"
131+ while IFS= read -r rust; do
113132 list_tag="$(./scripts/tag-names.sh \
114- --stellar-cli-version "$cli " --rust-version "$rust")"
133+ --stellar-cli-version "$STELLAR_CLI_VERSION " --rust-version "$rust")"
115134 amd64_tag="$(./scripts/tag-names.sh \
116- --stellar-cli-version "$cli " --rust-version "$rust" \
135+ --stellar-cli-version "$STELLAR_CLI_VERSION " --rust-version "$rust" \
117136 --platform linux/amd64)"
118137 arm64_tag="$(./scripts/tag-names.sh \
119- --stellar-cli-version "$cli " --rust-version "$rust" \
138+ --stellar-cli-version "$STELLAR_CLI_VERSION " --rust-version "$rust" \
120139 --platform linux/arm64)"
121140 if docker buildx imagetools inspect "$REGISTRY:$list_tag" >/dev/null 2>&1; then
122141 echo "::error::tag $REGISTRY:$list_tag already exists; manifest lists are immutable and never overwritten"
@@ -128,17 +147,18 @@ jobs:
128147 "$REGISTRY:$amd64_tag" \
129148 "$REGISTRY:$arm64_tag"
130149 echo "::endgroup::"
131- done < <(jq -c '
150+ done < <(jq -r --arg v "$STELLAR_CLI_VERSION" '
132151 .stellar_cli_versions[]
133- | .version as $v
152+ | select( .version == $v)
134153 | .rust_versions[]
135- | {cli: $v, rust: .}
136154 ' builds.json)
137155
138156 aliases :
139157 name : publish moving aliases
140- needs : manifest
158+ needs : [matrix, manifest]
141159 runs-on : ubuntu-24.04
160+ env :
161+ STELLAR_CLI_VERSION : ${{ needs.matrix.outputs.stellar_cli_version }}
142162 steps :
143163 - name : checkout
144164 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -151,25 +171,26 @@ jobs:
151171 password : ${{ secrets.DOCKERHUB_TOKEN }}
152172 - name : publish :<cli> and :latest aliases
153173 run : |
174+ default_rust="$(jq -r --arg v "$STELLAR_CLI_VERSION" \
175+ '.stellar_cli_versions[] | select(.version == $v) | .default_rust' \
176+ builds.json | head -n1)"
177+ target_tag="$(./scripts/tag-names.sh \
178+ --stellar-cli-version "$STELLAR_CLI_VERSION" \
179+ --rust-version "$default_rust")"
180+ target="$REGISTRY:$target_tag"
181+
182+ echo "::group::alias $REGISTRY:$STELLAR_CLI_VERSION -> $target"
183+ docker buildx imagetools create --tag "$REGISTRY:$STELLAR_CLI_VERSION" "$target"
184+ echo "::endgroup::"
185+
154186 newest_cli="$(./scripts/newest-pair.sh --stellar-cli-version)"
155- while IFS= read -r cli; do
156- default_rust="$(jq -r --arg cli "$cli" \
157- '.stellar_cli_versions[] | select(.version == $cli) | .default_rust' \
158- builds.json | head -n1)"
159- target_tag="$(./scripts/tag-names.sh \
160- --stellar-cli-version "$cli" --rust-version "$default_rust")"
161- target="$REGISTRY:$target_tag"
162-
163- echo "::group::alias $REGISTRY:$cli -> $target"
164- docker buildx imagetools create --tag "$REGISTRY:$cli" "$target"
187+ if [ "$STELLAR_CLI_VERSION" = "$newest_cli" ]; then
188+ echo "::group::alias $REGISTRY:latest -> $target"
189+ docker buildx imagetools create --tag "$REGISTRY:latest" "$target"
165190 echo "::endgroup::"
166-
167- if [ "$cli" = "$newest_cli" ]; then
168- echo "::group::alias $REGISTRY:latest -> $target"
169- docker buildx imagetools create --tag "$REGISTRY:latest" "$target"
170- echo "::endgroup::"
171- fi
172- done < <(jq -r '.stellar_cli_versions[].version' builds.json)
191+ else
192+ echo "cli $STELLAR_CLI_VERSION is not the newest ($newest_cli); skipping :latest"
193+ fi
173194
174195 complete :
175196 if : always()
0 commit comments