Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): Added release step for tag #49

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
name: pull request
on:
pull_request:
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
jobs:
pr-build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
steps:
- name: Checkout
uses: actions/checkout@v4
-
name: Build to test
with:
fetch-depth: 0
- name: Commitsar check
uses: aevea/[email protected]
- name: Build to test
env:
SKIP_COMPRESS: "true"
run: make ci

13 changes: 12 additions & 1 deletion .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to Aliyun ACR
uses: docker/login-action@v3
with:
Expand All @@ -35,7 +37,9 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
env:
CROSS: tag
run: make github_ci
run: |
make github_ci
make release-note

- name: Prepare for packaging image
run: cp dist/* package/
Expand Down Expand Up @@ -68,3 +72,10 @@ jobs:
context: package
push: true
if: ${{ env.ALIYUN == 'true' }}
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist/*
body_path: dist/release-note
draft: true
6 changes: 4 additions & 2 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FROM aevea/release-notary:0.9.2 as tools

FROM registry.suse.com/bci/golang:1.22
ARG PROXY
ARG GOPROXY
Expand All @@ -16,10 +18,10 @@ RUN curl -sL https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${
RUN if [ "${ARCH}" == "amd64" ]; then \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.54.2; \
fi

COPY --from=tools /app/release-notary /usr/local/bin/
ENV CATTLE_DASHBOARD_UI_VERSION="v2.8.0-kube-explorer-ui-rc3"

ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS GOPROXY
ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS GOPROXY SKIP_COMPRESS GITHUB_REPOSITORY GITHUB_TOKEN
ENV DAPPER_SOURCE /go/src/github.com/cnrancher/kube-explorer
ENV DAPPER_OUTPUT ./bin ./dist
ENV DAPPER_DOCKER_SOCKET true
Expand Down
22 changes: 12 additions & 10 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -e
source "$(dirname $0)/version"
cd "$(dirname $0)/.."

rm -rf ./bin/* ./dist/*

OS_ARCH_ARG_LINUX="amd64 arm arm64"
OS_ARCH_ARG_DARWIN="amd64 arm64"
OS_ARCH_ARG_WINDOWS="amd64"
Expand Down Expand Up @@ -61,19 +63,19 @@ case "$CROSS" in
;;
esac

mkdir -p "$DAPPER_SOURCE/bin"
mkdir -p "$DAPPER_SOURCE/dist"
mkdir -p "./bin"
mkdir -p "./dist"

for f in ./bin/*; do
filename=$(basename "$f")
if [[ $filename != *darwin* ]]; then
upx -o "$DAPPER_SOURCE/dist/$filename" "bin/$filename" || true
fi
if [ -f "$DAPPER_SOURCE/dist/$filename" ]; then
echo "UPX done!"
if [[ $filename != *darwin* && -z "$SKIP_COMPRESS" ]]; then
if upx -o "./dist/$filename" "$f"; then
echo "UPX done for $filename!"
else
echo "UPX failed for $filename, copying original file."
cp "$f" "./dist/$filename"
fi
else
echo "Copy origin file as UPX failed!!!"
cp "bin/$filename" "$DAPPER_SOURCE/dist/$filename"
cp "$f" "./dist/$filename"
fi
done

42 changes: 42 additions & 0 deletions scripts/release-note
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env sh

set -e

source "$(dirname $0)/version"
cd "$(dirname $0)/.."

mkdir -p dist
TARGET_PATH="dist/release-note"

if [ -z "$(command -v release-notary)" ]; then
echo "release-notary is not found, skip generating release notes."
exit 0
fi

if [ -z "${GIT_TAG}" ]; then
echo "running this scrpit without tag, skip generating release notes."
exit 0
fi

GIT_TAG=$(echo "${GIT_TAG}" | grep -E "^v([0-9]+)\.([0-9]+)(\.[0-9]+)?(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$") || true

if [ "${GIT_TAG}" = "" ]; then
echo "git GIT_TAG is not validated, skip generating release notes."
exit 0
fi

for tag in $(git tag -l --sort=-v:refname); do
if [ "${tag}" = "${GIT_TAG}" ]; then
continue
fi
filterred=$(echo "${tag}" | grep -E "^v([0-9]+)\.([0-9]+)(\.[0-9]+)?(-rc[0-9]*)$") || true
if [ "${filterred}" = "" ]; then
echo "get real release tag ${tag}, stopping untag"
break
fi
git tag -d ${tag}
done

echo "following release notes will be published..."
release-notary publish -d 2>/dev/null | sed '1d' | sed '$d' > $TARGET_PATH
cat "$TARGET_PATH"