Repository navigation
159 lines (151 loc) · 5.73 KB
/
Copy pathrelease.yaml
File metadata and controls
159 lines (151 loc) · 5.73 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
# Releases the kits. Anyone with write access starts it on main from the
# Actions tab. scripts/release.sh plan finds the next version from the commit
# types since the last release, and also releases when lstk or the MCP server
# has a new release. Then CI runs, the kits are pushed with the version and
# signed, and the last job creates the tag and the GitHub release.
#
# The tag comes last, so a failed run leaves no tag. The tag ruleset lets only
# admins and deploy keys create v* tags, so the workflow pushes the tag with
# the deploy key in the release environment, which accepts only main.
name: Release
on:
workflow_dispatch:
inputs:
bump:
description: Version bump. auto reads the commit types, and skips the release when nothing changed.
type: choice
default: auto
options: [auto, patch, minor, major]
permissions:
contents: read
concurrency:
group: release
cancel-in-progress: false
jobs:
plan:
name: Plan the release
if: github.repository == 'localstack/docker-kit' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
outputs:
release: ${{ steps.plan.outputs.release }}
version: ${{ steps.plan.outputs.version }}
lstk_version: ${{ steps.plan.outputs.lstk_version }}
mcp_server_version: ${{ steps.plan.outputs.mcp_server_version }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Find the next version
id: plan
env:
BUMP: ${{ inputs.bump }}
GH_TOKEN: ${{ github.token }}
run: scripts/release.sh plan "$BUMP" | tee -a "$GITHUB_OUTPUT"
ci:
name: CI
needs: plan
if: needs.plan.outputs.release == 'true'
uses: ./.github/workflows/ci.yaml
publish:
name: Publish kits
needs: [plan, ci]
runs-on: ubuntu-24.04
environment:
name: docker-push
deployment: false
env:
VERSION: ${{ needs.plan.outputs.version }}
LSTK_VERSION: ${{ needs.plan.outputs.lstk_version }}
MCP_SERVER_VERSION: ${{ needs.plan.outputs.mcp_server_version }}
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
docker system prune --all --force
df -h /
- uses: docker/setup-qemu-action@v4
- uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
# The version has no git tag yet, so a Docker Hub tag with this version
# is from a failed run. The build can replace it.
- name: Build and push the kits
run: >-
scripts/build.sh --version "$VERSION" --allow-overwrite
--lstk-version "$LSTK_VERSION" --mcp-server-version "$MCP_SERVER_VERSION"
# A signing failure does not stop the release. Run this job again to sign.
sign:
name: Sign kits
needs: [plan, publish]
runs-on: ubuntu-24.04
environment:
name: docker-push
deployment: false
permissions:
contents: read
id-token: write # keyless signing with the GitHub OIDC token
env:
VERSION: ${{ needs.plan.outputs.version }}
steps:
- uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
- name: Install sbx
run: |
curl -fsSL https://get.docker.com | sudo REPO_ONLY=1 sh
sudo apt-get install -y docker-sbx
- name: Sign the kits
run: |
for image in sbx-kit-localstack sbx-localstack-claude sbx-localstack-codex; do
sbx kit sign "docker.io/localstack/$image:$VERSION"
done
release:
name: Create the tag and the release
needs: [plan, publish]
runs-on: ubuntu-24.04
environment:
name: release
deployment: false
permissions:
contents: write
env:
TAG: v${{ needs.plan.outputs.version }}
VERSION: ${{ needs.plan.outputs.version }}
LSTK_VERSION: ${{ needs.plan.outputs.lstk_version }}
MCP_SERVER_VERSION: ${{ needs.plan.outputs.mcp_server_version }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Write the release notes
run: scripts/release.sh notes "$VERSION" "$LSTK_VERSION" "$MCP_SERVER_VERSION" >"$RUNNER_TEMP/notes.md"
# GitHub publishes its SSH host keys in the meta API, so the push does
# not trust the first key that it sees.
- name: Push the tag
env:
DEPLOY_KEY: ${{ secrets.RELEASE_TAG_DEPLOY_KEY }}
GH_TOKEN: ${{ github.token }}
run: |
if git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null; then
echo "$TAG exists. An earlier run pushed it."
exit 0
fi
install -m 600 /dev/null "$RUNNER_TEMP/deploy-key"
printf '%s\n' "$DEPLOY_KEY" >"$RUNNER_TEMP/deploy-key"
gh api meta --jq '.ssh_keys[] | "github.com " + .' >"$RUNNER_TEMP/known_hosts"
git -c user.name="github-actions[bot]" \
-c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
tag -a "$TAG" -m "Release $TAG" "$GITHUB_SHA"
GIT_SSH_COMMAND="ssh -i $RUNNER_TEMP/deploy-key -o IdentitiesOnly=yes -o UserKnownHostsFile=$RUNNER_TEMP/known_hosts" \
git push "git@github.com:$GITHUB_REPOSITORY.git" "refs/tags/$TAG"
- name: Create the release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$TAG" --verify-tag --title "$TAG" --notes-file "$RUNNER_TEMP/notes.md"