-
Notifications
You must be signed in to change notification settings - Fork 184
200 lines (177 loc) · 6.97 KB
/
Copy pathbundle-pre-seed-utils.yml
File metadata and controls
200 lines (177 loc) · 6.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Bundle pre_seed utils
on:
workflow_dispatch:
inputs:
aws_cli_version:
description: 'AWS CLI v2 version (leave empty for latest)'
required: false
default: ''
ghpool_version:
description: 'ghpool version (leave empty for latest)'
required: false
default: ''
upload_s3:
description: 'Also upload to S3 (openab-state-pahud/shared/utils.tar.gz)'
required: false
type: boolean
default: false
permissions:
contents: write
env:
ARTIFACT_NAME: pre-seed-utils
jobs:
resolve:
runs-on: ubuntu-latest
outputs:
aws_cli_version: ${{ steps.versions.outputs.aws_cli_version }}
ghpool_version: ${{ steps.versions.outputs.ghpool_version }}
steps:
- name: Resolve versions
id: versions
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INPUT_AWS_CLI_VERSION: ${{ inputs.aws_cli_version }}
INPUT_GHPOOL_VERSION: ${{ inputs.ghpool_version }}
run: |
# AWS CLI version
if [ -n "$INPUT_AWS_CLI_VERSION" ]; then
AWS_VER="$INPUT_AWS_CLI_VERSION"
else
AWS_VER=$(curl -fsSL https://raw.githubusercontent.com/aws/aws-cli/v2/CHANGELOG.rst | grep -m1 '^[0-9]' | cut -d' ' -f1)
echo "Resolved latest AWS CLI: $AWS_VER"
fi
echo "aws_cli_version=${AWS_VER}" >> "$GITHUB_OUTPUT"
# ghpool version
if [ -n "$INPUT_GHPOOL_VERSION" ]; then
GHP_VER="$INPUT_GHPOOL_VERSION"
else
GHP_VER=$(gh release view --repo openabdev/ghpool --json tagName -q '.tagName' | sed 's/^v//')
echo "Resolved latest ghpool: $GHP_VER"
fi
echo "ghpool_version=${GHP_VER}" >> "$GITHUB_OUTPUT"
- name: Summary
env:
AWS_CLI_VERSION: ${{ steps.versions.outputs.aws_cli_version }}
GHPOOL_VERSION: ${{ steps.versions.outputs.ghpool_version }}
run: |
echo "### Resolved Versions" >> "$GITHUB_STEP_SUMMARY"
echo "- AWS CLI: ${AWS_CLI_VERSION}" >> "$GITHUB_STEP_SUMMARY"
echo "- ghpool: ${GHPOOL_VERSION}" >> "$GITHUB_STEP_SUMMARY"
bundle:
needs: resolve
strategy:
matrix:
include:
- { arch: x86_64, runner: ubuntu-latest, awscli_arch: x86_64, ghpool_arch: linux-x64 }
- { arch: aarch64, runner: ubuntu-24.04-arm, awscli_arch: aarch64, ghpool_arch: linux-arm64 }
runs-on: ${{ matrix.runner }}
steps:
- name: Install AWS CLI v2
env:
AWS_CLI_VERSION: ${{ needs.resolve.outputs.aws_cli_version }}
run: |
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-${{ matrix.awscli_arch }}-${AWS_CLI_VERSION}.zip" -o /tmp/awscli.zip
unzip -q /tmp/awscli.zip -d /tmp
/tmp/aws/install --install-dir ./aws-cli --bin-dir ./bin
rm -rf /tmp/aws /tmp/awscli.zip
- name: Download ghp from ghpool release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GHP_VER: ${{ needs.resolve.outputs.ghpool_version }}
run: |
gh release download "v${GHP_VER}" \
--repo openabdev/ghpool \
--pattern "ghpool-${GHP_VER}-${{ matrix.ghpool_arch }}.tar.gz" \
--dir /tmp
tar -xzf /tmp/ghpool-${GHP_VER}-${{ matrix.ghpool_arch }}.tar.gz -C /tmp
# ghpool tarball contains 'ghp' binary
cp /tmp/ghp ./bin/ghp
chmod +x ./bin/ghp
- name: Symlink gh to ghp
run: |
cd bin && ln -sf ghp gh && cd ..
- name: Fix symlinks to be relative
run: |
# AWS CLI installer creates absolute symlinks in bin/ — replace with relative
rm -f ./bin/aws ./bin/aws_completer
# Find the installed version directory
VERSION_DIR=$(ls ./aws-cli/v2/ | grep -v current)
# Recreate relative symlinks
cd aws-cli/v2 && rm -f current && ln -sf "$VERSION_DIR" current && cd ../..
cd bin && ln -sf ../aws-cli/v2/current/bin/aws aws && ln -sf ../aws-cli/v2/current/bin/aws_completer aws_completer && cd ..
- name: Verify symlinks
run: |
echo "=== bin/ ==="
ls -la ./bin/
echo "=== aws-cli/v2/ ==="
ls -la ./aws-cli/v2/
echo "=== resolve test ==="
./bin/aws --version
./bin/ghp --version
# gh should resolve to ghp
test "$(readlink ./bin/gh)" = "ghp"
- name: Create tarball
run: |
tar -czf utils-${{ matrix.arch }}.tar.gz ./bin ./aws-cli
ls -lh utils-${{ matrix.arch }}.tar.gz
echo "### Contents" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
tar -tvf utils-${{ matrix.arch }}.tar.gz | grep -E "(\->|bin/)" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}-${{ matrix.arch }}
path: utils-${{ matrix.arch }}.tar.gz
retention-days: 30
release:
needs: [resolve, bundle]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: ${{ env.ARTIFACT_NAME }}-*
merge-multiple: true
- name: List artifacts
run: ls -lh artifacts/
- name: Upload to GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_CLI_VERSION: ${{ needs.resolve.outputs.aws_cli_version }}
GHPOOL_VERSION: ${{ needs.resolve.outputs.ghpool_version }}
run: |
TAG="pre-seed-utils-v${AWS_CLI_VERSION}-ghp${GHPOOL_VERSION}"
gh release create "$TAG" \
--repo ${{ github.repository }} \
--title "pre_seed utils (AWS CLI ${AWS_CLI_VERSION} + ghp ${GHPOOL_VERSION})" \
--notes "Bundled pre_seed utilities for OAB fleet.
**Contents:**
- AWS CLI v${AWS_CLI_VERSION}
- ghp v${GHPOOL_VERSION} (ghpool shim)
- gh → ghp symlink
**Usage:** Add to \`[hooks.pre_seed].sources\` as S3 URI after uploading." \
artifacts/utils-x86_64.tar.gz \
artifacts/utils-aarch64.tar.gz
upload-s3:
needs: [resolve, bundle]
if: inputs.upload_s3
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1
- name: Download x86_64 artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}-x86_64
- name: Upload to S3
run: |
aws s3 cp utils-x86_64.tar.gz s3://openab-state-pahud/shared/utils.tar.gz
echo "✅ Uploaded to s3://openab-state-pahud/shared/utils.tar.gz"