Skip to content

Commit c2af9fb

Browse files
authored
ci(bundle-utils): auto-resolve latest AWS CLI and ghpool versions (#1253)
Default inputs to empty, add resolve job that fetches: - AWS CLI latest from CHANGELOG.rst - ghpool latest from GitHub release tag Co-authored-by: chaodu-agent <chaodu-agent@users.noreply.github.com>
1 parent 948f64f commit c2af9fb

1 file changed

Lines changed: 53 additions & 16 deletions

File tree

.github/workflows/bundle-pre-seed-utils.yml

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ on:
44
workflow_dispatch:
55
inputs:
66
aws_cli_version:
7-
description: 'AWS CLI v2 version (e.g. 2.35.12)'
8-
required: true
9-
default: '2.35.12'
7+
description: 'AWS CLI v2 version (leave empty for latest)'
8+
required: false
9+
default: ''
1010
ghpool_version:
11-
description: 'ghpool version (e.g. 0.3.2)'
12-
required: true
13-
default: '0.3.2'
11+
description: 'ghpool version (leave empty for latest)'
12+
required: false
13+
default: ''
1414
upload_s3:
1515
description: 'Also upload to S3 (openab-state-pahud/shared/utils.tar.gz)'
1616
required: false
@@ -24,7 +24,43 @@ env:
2424
ARTIFACT_NAME: pre-seed-utils
2525

2626
jobs:
27+
resolve:
28+
runs-on: ubuntu-latest
29+
outputs:
30+
aws_cli_version: ${{ steps.versions.outputs.aws_cli_version }}
31+
ghpool_version: ${{ steps.versions.outputs.ghpool_version }}
32+
steps:
33+
- name: Resolve versions
34+
id: versions
35+
env:
36+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
# AWS CLI version
39+
if [ -n "${{ inputs.aws_cli_version }}" ]; then
40+
AWS_VER="${{ inputs.aws_cli_version }}"
41+
else
42+
AWS_VER=$(curl -fsSL https://raw.githubusercontent.com/aws/aws-cli/v2/CHANGELOG.rst | grep -m1 '^[0-9]' | cut -d' ' -f1)
43+
echo "Resolved latest AWS CLI: $AWS_VER"
44+
fi
45+
echo "aws_cli_version=${AWS_VER}" >> "$GITHUB_OUTPUT"
46+
47+
# ghpool version
48+
if [ -n "${{ inputs.ghpool_version }}" ]; then
49+
GHP_VER="${{ inputs.ghpool_version }}"
50+
else
51+
GHP_VER=$(gh release view --repo openabdev/ghpool --json tagName -q '.tagName' | sed 's/^v//')
52+
echo "Resolved latest ghpool: $GHP_VER"
53+
fi
54+
echo "ghpool_version=${GHP_VER}" >> "$GITHUB_OUTPUT"
55+
56+
- name: Summary
57+
run: |
58+
echo "### Resolved Versions" >> "$GITHUB_STEP_SUMMARY"
59+
echo "- AWS CLI: ${{ steps.versions.outputs.aws_cli_version }}" >> "$GITHUB_STEP_SUMMARY"
60+
echo "- ghpool: ${{ steps.versions.outputs.ghpool_version }}" >> "$GITHUB_STEP_SUMMARY"
61+
2762
bundle:
63+
needs: resolve
2864
strategy:
2965
matrix:
3066
include:
@@ -34,7 +70,7 @@ jobs:
3470
steps:
3571
- name: Install AWS CLI v2
3672
run: |
37-
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-${{ matrix.awscli_arch }}-${{ inputs.aws_cli_version }}.zip" -o /tmp/awscli.zip
73+
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-${{ matrix.awscli_arch }}-${{ needs.resolve.outputs.aws_cli_version }}.zip" -o /tmp/awscli.zip
3874
unzip -q /tmp/awscli.zip -d /tmp
3975
/tmp/aws/install --install-dir ./aws-cli --bin-dir ./bin
4076
rm -rf /tmp/aws /tmp/awscli.zip
@@ -45,11 +81,12 @@ jobs:
4581
env:
4682
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4783
run: |
48-
gh release download "v${{ inputs.ghpool_version }}" \
84+
GHP_VER="${{ needs.resolve.outputs.ghpool_version }}"
85+
gh release download "v${GHP_VER}" \
4986
--repo openabdev/ghpool \
50-
--pattern "ghpool-${{ inputs.ghpool_version }}-${{ matrix.ghpool_arch }}.tar.gz" \
87+
--pattern "ghpool-${GHP_VER}-${{ matrix.ghpool_arch }}.tar.gz" \
5188
--dir /tmp
52-
tar -xzf /tmp/ghpool-${{ inputs.ghpool_version }}-${{ matrix.ghpool_arch }}.tar.gz -C /tmp
89+
tar -xzf /tmp/ghpool-${GHP_VER}-${{ matrix.ghpool_arch }}.tar.gz -C /tmp
5390
# ghpool tarball contains 'ghp' binary
5491
cp /tmp/ghp ./bin/ghp
5592
chmod +x ./bin/ghp
@@ -100,7 +137,7 @@ jobs:
100137
retention-days: 30
101138

102139
release:
103-
needs: bundle
140+
needs: [resolve, bundle]
104141
runs-on: ubuntu-latest
105142
steps:
106143
- name: Download all artifacts
@@ -117,23 +154,23 @@ jobs:
117154
env:
118155
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119156
run: |
120-
TAG="utils-v${{ inputs.aws_cli_version }}-ghp${{ inputs.ghpool_version }}"
157+
TAG="utils-v${{ needs.resolve.outputs.aws_cli_version }}-ghp${{ needs.resolve.outputs.ghpool_version }}"
121158
gh release create "$TAG" \
122159
--repo ${{ github.repository }} \
123-
--title "pre_seed utils (AWS CLI ${{ inputs.aws_cli_version }} + ghp ${{ inputs.ghpool_version }})" \
160+
--title "pre_seed utils (AWS CLI ${{ needs.resolve.outputs.aws_cli_version }} + ghp ${{ needs.resolve.outputs.ghpool_version }})" \
124161
--notes "Bundled pre_seed utilities for OAB fleet.
125162
126163
**Contents:**
127-
- AWS CLI v${{ inputs.aws_cli_version }}
128-
- ghp v${{ inputs.ghpool_version }} (ghpool shim)
164+
- AWS CLI v${{ needs.resolve.outputs.aws_cli_version }}
165+
- ghp v${{ needs.resolve.outputs.ghpool_version }} (ghpool shim)
129166
- gh CLI (from runner)
130167
131168
**Usage:** Add to \`[hooks.pre_seed].sources\` as S3 URI after uploading." \
132169
artifacts/utils-x86_64.tar.gz \
133170
artifacts/utils-aarch64.tar.gz
134171
135172
upload-s3:
136-
needs: bundle
173+
needs: [resolve, bundle]
137174
if: inputs.upload_s3
138175
runs-on: ubuntu-latest
139176
permissions:

0 commit comments

Comments
 (0)