-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(provisioning): add cloudformation templates and related GHA (#42)
Signed-off-by: francesco-racciatti <[email protected]>
- Loading branch information
1 parent
eddc7b6
commit acfa2d6
Showing
4 changed files
with
923 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: promote | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_version: | ||
description: 'The release version, e.g. 5.0.0.' | ||
type: string | ||
required: true | ||
|
||
rc_number: | ||
description: 'The release candidate number to promote, e.g. 1.' | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
promote: | ||
env: | ||
RC_NAME: ${{ inputs.release_version }}-rc${{ inputs.rc_tag }} | ||
name: Promote | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Verify inputs | ||
shell: bash | ||
run: | | ||
if [[ ! "${{ inputs.release_version }}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | ||
echo "The provided release version is not valid" | ||
exit 1 | ||
fi | ||
if [[ ! "${{ inputs.rc_number }}" =~ ^([0-9])+$ ]]; then | ||
echo "The provided rc tag is not valid" | ||
exit 1 | ||
fi | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Promote RC Tag | ||
shell: bash | ||
run: | | ||
if ! git rev-parse "${RC_NAME}" &>/dev/null; then | ||
echo "The RC Tag ${RC_NAME} does not exist" | ||
exit 1 | ||
fi | ||
git fetch --tags | ||
git tag "${{ inputs.release_version }}" "${RC_NAME}" | ||
git push -u origin "${{ inputs.release_version }}" | ||
- name: Get resources from RC | ||
shell: bash | ||
run: | | ||
rm -f cloudformation.zip | ||
rm -f checksums.txt | ||
curl -L "https://github.com/${{ github.repository }}/releases/download/${RC_NAME}/cloudformation.zip" > cloudformation.zip | ||
curl -L "https://github.com/${{ github.repository }}/releases/download/${RC_NAME}/checksums.txt" > checksums.txt | ||
- name: Create release | ||
uses: softprops/action-gh-release@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
files: | | ||
cloudformation.zip | ||
checksums.txt | ||
name: ${{ inputs.release_version }} | ||
tag_name: ${{ inputs.release_version }} | ||
prerelease: false | ||
make_latest: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,96 @@ | ||
name: Release agent-kilt | ||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
workflow_dispatch: | ||
inputs: | ||
release_version: | ||
description: 'The release version, e.g. 5.0.0.' | ||
type: string | ||
required: true | ||
|
||
env: | ||
GO_VERSION: 1.21.x | ||
rc_number: | ||
description: 'The release candidate number, e.g. 1.' | ||
type: string | ||
required: true | ||
|
||
serverless_agent_version: | ||
description: 'The version of the serverless-agent to be referenced by this release, e.g., 4.0.0. It will use the same version as the release if not specified.' | ||
type: string | ||
required: false | ||
|
||
jobs: | ||
release: | ||
env: | ||
RC_NAME: ${{ inputs.release_version }}-rc${{ inputs.rc_number }} | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
id: go | ||
- name: Verify inputs | ||
shell: bash | ||
run: | | ||
if [[ ! "${{ inputs.release_version }}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | ||
echo "The provided release version is not valid" | ||
exit 1 | ||
fi | ||
if [[ ! "${{ inputs.rc_number }}" =~ ^([0-9])+$ ]]; then | ||
echo "The provided rc tag is not valid" | ||
exit 1 | ||
fi | ||
docker pull "quay.io/sysdig/workload-agent:${{ inputs.serverless_agent_version }}" &> /dev/null | ||
exit_code=$? | ||
if [[ $exit_code -ne 0 ]]; then | ||
echo "The provided serverless_agent_version does not exists." | ||
exit 1 | ||
fi | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Build agent-kilt handler | ||
- name: Push RC tag | ||
shell: bash | ||
run: | | ||
git fetch --tags | ||
if git rev-parse "${RC_NAME}" &> /dev/null; then | ||
echo "The tag ${RC_NAME} already exists" | ||
exit 1 | ||
fi | ||
git tag "${RC_NAME}" | ||
git push -u origin "${RC_NAME}" | ||
- name: Prepare dist package | ||
shell: bash | ||
run: | | ||
rm -rf dist | ||
mkdir -p dist/provisioning/cloudformation | ||
- name: Add versioned CloudFormation templates | ||
env: | ||
RELEASE_VERSION: ${{ inputs.release_version }} | ||
SERVERLESS_AGENT_VERSION: ${{ inputs.serverless_agent_version || inputs.release_version }} | ||
shell: bash | ||
run: | | ||
make -C runtimes/cloudformation clean cmd/handler/handler | ||
script="s/(dev)/${RELEASE_VERSION}/g; s/agent:latest/agent:${SERVERLESS_AGENT_VERSION}/g" | ||
sed "$script" provisioning/cloudformation/orchestrator-agent.yaml > dist/provisioning/cloudformation/orchestrator-agent.yaml | ||
sed "$script" provisioning/cloudformation/instrumentation.yaml > dist/provisioning/cloudformation/instrumentation.yaml | ||
- name: Archive build | ||
- name: Create prerelease attachments | ||
shell: bash | ||
run: | | ||
zip -j agent-kilt.zip runtimes/cloudformation/cmd/handler/handler | ||
sha256sum agent-kilt.zip > checksums.txt | ||
pushd dist/provisioning; zip -r ../../cloudformation.zip .; popd | ||
sha256sum cloudformation.zip > checksums.txt | ||
- name: Create GitHub Release | ||
id: create_release | ||
uses: softprops/action-gh-release@v1 | ||
- name: Create prerelease | ||
uses: softprops/action-gh-release@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
files: | | ||
agent-kilt.zip | ||
cloudformation.zip | ||
checksums.txt | ||
tag_name: ${{ github.ref }} | ||
name: ${RC_NAME} | ||
tag_name: ${RC_NAME} | ||
prerelease: true |
Oops, something went wrong.