Skip to content

CDK CI

CDK CI #21

name: CDK CI
on:
release:
types: [released]
jobs:
release:
name: Build and Release
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.15
- uses: actions/setup-node@v1
with:
node-version: 10.x
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/download-artifact@v2
- name: Upload Release and Renew Changelog
env:
UPLOAD_URL: ${{ github.event.release.upload_url }}
API_HEADER: "Accept: application/vnd.github.v3+json"
AUTH_HEADER: "Authorization: token ${{ secrets.GITHUB_TOKEN }}"
RELEASE_URL: ${{ github.event.release.url }}
run: |
set -x
go get github.com/mitchellh/gox
sudo apt-get install -y upx
export CGO_ENABLED=0
export GIT_COMMIT=$(git rev-list -1 HEAD)
export ldflags="-X github.com/cdk-team/CDK/pkg/cli.GitCommit=$GIT_COMMIT"
gox -parallel 5 -osarch="darwin/amd64 linux/386 linux/amd64 linux/arm linux/arm64" -ldflags="-s -w $ldflags " -output="bin/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/cdk/
gox -parallel 5 -osarch="linux/386 linux/amd64 linux/arm64" -ldflags="-s -w $ldflags " -tags="thin" -output="bin/{{.Dir}}_{{.OS}}_{{.Arch}}_thin" ./cmd/cdk/
# cdk_linux_386 cdk_linux_amd64 cdk_linux_arm cdk_linux_arm64
cp bin/cdk_linux_amd64 bin/cdk_linux_amd64_upx
upx bin/cdk_linux_amd64_upx
cp bin/cdk_linux_386 bin/cdk_linux_386_upx
upx bin/cdk_linux_386_upx
cp bin/cdk_linux_amd64_thin bin/cdk_linux_amd64_thin_upx
upx bin/cdk_linux_amd64_thin_upx
cp bin/cdk_linux_386_thin bin/cdk_linux_386_thin_upx
upx bin/cdk_linux_386_thin_upx
UPLOAD_URL=$(echo -n $UPLOAD_URL | sed s/\{.*//g)
for FILE in bin/*
do
echo "Uploading ${FILE}";
curl \
-H "${API_HEADER}" \
-H "${AUTH_HEADER}" \
-H "Content-Type: $(file -b --mime-type ${FILE})" \
--data-binary "@${FILE}" \
"${UPLOAD_URL}?name=$(basename ${FILE})";
done
bash ".github/workflows/changelog.sh"