forked from awslabs/soci-snapshotter
-
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.
Signed-off-by: David Son <[email protected]>
- Loading branch information
Showing
3 changed files
with
161 additions
and
1 deletion.
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,84 @@ | ||
name: Release | ||
|
||
on: | ||
create: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
env: | ||
GO_VERSION: '1.20.6' | ||
|
||
permissions: | ||
contents: write | ||
deployments: write | ||
|
||
jobs: | ||
# Any way we can just call build.yml? | ||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
- run: make | ||
- run: make test | ||
|
||
integration: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
containerd: ["1.6.19", "1.7.0"] | ||
env: | ||
DOCKER_BUILD_ARGS: "CONTAINERD_VERSION=${{ matrix.containerd }}" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
- run: make integration | ||
|
||
generate-artifacts: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup and export variables | ||
run: | | ||
export release_tag=${GITHUB_REF#refs/*/} # Strip down to raw tag name | ||
export release_version=${release_tag/v/} # Remove v from tag name | ||
echo "release_tag=${release_tag}">> $GITHUB_ENV | ||
echo "dynamic_binary_name=soci-snapshotter-${release_version}-linux-amd64.tar.gz" >> $GITHUB_ENV | ||
echo "static_binary_name=soci-snapshotter-${release_version}-linux-amd64-static.tar.gz" >> $GITHUB_ENV | ||
mkdir release | ||
- name: Create release binaries | ||
run: make RELEASE_TAG=${{ env.release_tag }} release | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: artifacts | ||
path: release/ | ||
if-no-files-found: error | ||
|
||
outputs: | ||
dynamic_binary_name: ${{ env.dynamic_binary_name }} | ||
static_binary_name: ${{ env.static_binary_name }} | ||
|
||
create-release: | ||
needs: generate-artifacts | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: artifacts | ||
- uses: softprops/action-gh-release@v1 | ||
with: | ||
draft: true | ||
prerelease: false | ||
generate_release_notes: true | ||
files: | | ||
${{ needs.generate-artifacts.outputs.dynamic_binary_name }} | ||
${{ needs.generate-artifacts.outputs.dynamic_binary_name }}.sha256sum | ||
${{ needs.generate-artifacts.outputs.static_binary_name }} | ||
${{ needs.generate-artifacts.outputs.static_binary_name }}.sha256sum |
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
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 @@ | ||
#!/bin/bash | ||
|
||
# Copyright The Soci Snapshotter Authors. | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# A script to generate release artifacts. | ||
# This will create a folder in your project root called release. | ||
# This will contain the dynamic + static binaries | ||
# as well as their respective sha256 checksums. | ||
# NOTE: this will mutate your $SOCI_SNAPSHOTTER_PROJECT_ROOT/out folder. | ||
|
||
set -eux -o pipefail | ||
|
||
CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
SOCI_SNAPSHOTTER_PROJECT_ROOT="$(cd -- "$CUR_DIR"/.. && pwd)" | ||
OUT_DIR="${SOCI_SNAPSHOTTER_PROJECT_ROOT}/out" | ||
RELEASE_DIR="${SOCI_SNAPSHOTTER_PROJECT_ROOT}/release" | ||
LICENSE_FILE=${SOCI_SNAPSHOTTER_PROJECT_ROOT}/THIRD_PARTY_LICENSES | ||
NOTICE_FILE=${SOCI_SNAPSHOTTER_PROJECT_ROOT}/NOTICE.md | ||
TAG_REGEX="v[0-9]+.[0-9]+.[0-9]+" | ||
|
||
ARCH="" | ||
case $(uname -m) in | ||
x86_64) ARCH="amd64" ;; | ||
aarch64) ARCH="arm64" ;; | ||
*) echo "Error: Unsupported arch"; exit 1 ;; | ||
esac | ||
|
||
if [ "$#" -ne 1 ]; then | ||
echo "Expected 1 parameter, got $#." | ||
echo "Usage: $0 [release_tag]" | ||
exit 1 | ||
fi | ||
|
||
if ! [[ "$1" =~ $TAG_REGEX ]]; then | ||
echo "Improper tag format. Format should match regex $TAG_REGEX" | ||
exit 1 | ||
fi | ||
|
||
if [ -d $RELEASE_DIR ]; then | ||
rm -rf $RELEASE_DIR/* | ||
else | ||
mkdir $RELEASE_DIR | ||
fi | ||
|
||
release_version=${1/v/} # Remove v from tag name | ||
dynamic_binary_name=soci-snapshotter-${release_version}-linux-${ARCH}.tar.gz | ||
static_binary_name=soci-snapshotter-${release_version}-linux-${ARCH}-static.tar.gz | ||
|
||
make build | ||
cp $NOTICE_FILE $LICENSE_FILE $OUT_DIR | ||
tar -czvf $RELEASE_DIR/$dynamic_binary_name $OUT_DIR | ||
rm -rf $OUT_DIR/* | ||
|
||
make build | ||
cp $NOTICE_FILE $LICENSE_FILE $OUT_DIR | ||
tar -czvf $RELEASE_DIR/$static_binary_name $OUT_DIR | ||
rm -rf $OUT_DIR/* | ||
|
||
sha256sum $RELEASE_DIR/$dynamic_binary_name > $RELEASE_DIR/$dynamic_binary_name.sha256sum | ||
sha256sum $RELEASE_DIR/$static_binary_name > $RELEASE_DIR/$static_binary_name.sha256sum |