CDK v1.5.4 #23
Workflow file for this run
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
name: CDK CI | |
on: | |
workflow_dispatch: | |
release: | |
types: [released, prereleased] | |
jobs: | |
release: | |
name: Build and Release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: 1.22.2 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: 10.x | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v4 | |
- 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 -euo pipefail | |
set -x | |
sudo apt-get update | |
sudo apt-get install -y upx file curl | |
export CGO_ENABLED=0 | |
export GIT_COMMIT=$(git rev-list -1 HEAD) | |
export ldflags="-s -w -extldflags \"-static\" -X github.com/cdk-team/CDK/pkg/cli.GitCommit=$GIT_COMMIT" | |
mkdir -p bin | |
echo "Building standard versions..." | |
GOOS=darwin GOARCH=amd64 go build -ldflags="$ldflags" -o bin/cdk_darwin_amd64 ./cmd/cdk/ || echo "Darwin build failed" | |
GOOS=linux GOARCH=386 go build -ldflags="$ldflags" -o bin/cdk_linux_386 ./cmd/cdk/ | |
GOOS=linux GOARCH=amd64 go build -ldflags="$ldflags" -o bin/cdk_linux_amd64 ./cmd/cdk/ | |
GOOS=linux GOARCH=arm go build -ldflags="$ldflags" -o bin/cdk_linux_arm ./cmd/cdk/ | |
GOOS=linux GOARCH=arm64 go build -ldflags="$ldflags" -o bin/cdk_linux_arm64 ./cmd/cdk/ | |
echo "Building thin versions..." | |
GOOS=linux GOARCH=386 go build -ldflags="$ldflags" -tags="thin" -o bin/cdk_linux_386_thin ./cmd/cdk/ | |
GOOS=linux GOARCH=amd64 go build -ldflags="$ldflags" -tags="thin" -o bin/cdk_linux_amd64_thin ./cmd/cdk/ | |
GOOS=linux GOARCH=arm64 go build -ldflags="$ldflags" -tags="thin" -o bin/cdk_linux_arm64_thin ./cmd/cdk/ | |
echo "Creating UPX compressed versions..." | |
for file in bin/cdk_linux_{386,amd64}{,_thin}; do | |
if [ -f "$file" ]; then | |
cp "$file" "${file}_upx" | |
upx "${file}_upx" || echo "UPX compression failed for ${file}" | |
fi | |
done | |
UPLOAD_URL=$(echo -n $UPLOAD_URL | sed s/\{.*//g) | |
echo "Uploading files..." | |
for FILE in bin/*; do | |
if [ -f "$FILE" ]; then | |
echo "Uploading ${FILE}" | |
MIME_TYPE=$(file -b --mime-type "${FILE}") | |
RESPONSE=$(curl -w "%{http_code}" \ | |
-H "${API_HEADER}" \ | |
-H "${AUTH_HEADER}" \ | |
-H "Content-Type: ${MIME_TYPE}" \ | |
--data-binary "@${FILE}" \ | |
"${UPLOAD_URL}?name=$(basename ${FILE})" \ | |
-o /dev/null) | |
if [ "$RESPONSE" -ne 201 ]; then | |
echo "Error uploading ${FILE}, status code: ${RESPONSE}" | |
fi | |
fi | |
done | |
bash ".github/workflows/changelog.sh" | |