From 92db9f5d1355229aa46f47e3af8001674272fb25 Mon Sep 17 00:00:00 2001 From: Pavindu Lakshan Date: Wed, 16 Apr 2025 16:54:00 +0530 Subject: [PATCH 1/6] Add release workflow --- .github/scripts/release.sh | 41 ++++++++++++++++++++--------------- .github/workflows/release.yml | 3 +++ Makefile | 3 +++ 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/.github/scripts/release.sh b/.github/scripts/release.sh index 35568a2..3cc1041 100644 --- a/.github/scripts/release.sh +++ b/.github/scripts/release.sh @@ -13,36 +13,41 @@ set -e set -o pipefail UPSTREAM_BRANCH="main" +# Check the number of arguments passed. +if [ "$#" -ne 3 ]; then + echo "Error: Invalid or insufficient arguments provided!" >&2 + echo "Usage: $0 " >&2 + exit 1 +fi # Assign command line arguments to variables. GIT_TOKEN=$1 WORK_DIR=$2 VERSION_TYPE=$3 # possible values: major, minor, patch - Check if GIT_TOKEN is empty -if [ -z "$GIT_TOKEN" ]; then - echo "❌ Error: GIT_TOKEN is not set." - exit 1 -fi - -# Check if WORK_DIR is empty -if [ -z "$WORK_DIR" ]; then - echo "❌ Error: WORK_DIR is not set." - exit 1 -fi - -# Validate VERSION_TYPE -if [[ "$VERSION_TYPE" != "major" && "$VERSION_TYPE" != "minor" && "$VERSION_TYPE" != "patch" ]]; then - echo "❌ Error: VERSION_TYPE must be one of: major, minor, or patch." - exit 1 -fi - BUILD_DIRECTORY="$WORK_DIR/build" RELEASE_DIRECTORY="$BUILD_DIRECTORY/releases" +# Configuration variables. +GIT_EMAIL="iam-cloud@wso2.com" +GIT_USERNAME="wso2-iam-cloud-bot" +UPSTREAM_REPO_URL="https://github.com/wso2/open-mcp-auth-proxy.git" +UPSTREAM_BRANCH="main" + +# Configure git. +git config --global user.email "${GIT_EMAIL}" +git config --global user.name "${GIT_USERNAME}" + # Navigate to the working directory. cd "${WORK_DIR}" +# Set 'origin' to point to the upstream repository. +git remote set-url origin "${UPSTREAM_REPO_URL}" + +# Ensure the latest changes are pulled. +git checkout ${UPSTREAM_BRANCH} +git pull + # Create the release directory. if [ ! -d "$RELEASE_DIRECTORY" ]; then mkdir -p "$RELEASE_DIRECTORY" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e55f6b6..63e56b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,9 @@ name: Release on: + pull_request: + branches: [ main ] + types: [closed] workflow_dispatch: inputs: version_type: diff --git a/Makefile b/Makefile index c9ef883..1a8495b 100644 --- a/Makefile +++ b/Makefile @@ -31,18 +31,21 @@ build: clean test build-linux build-linux-arm build-darwin build-linux: mkdir -p $(BUILD_DIR)/linux GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -x -ldflags "-X main.version=$(BUILD_VERSION) \ + -X 'main.buildDate=$$(date -u '+%Y-%m-%d %H:%M:%S UTC')'" \ -o $(BUILD_DIR)/linux/openmcpauthproxy $(PROJECT_ROOT)/cmd/proxy cp config.yaml $(BUILD_DIR)/linux build-linux-arm: mkdir -p $(BUILD_DIR)/linux-arm GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -x -ldflags "-X main.version=$(BUILD_VERSION) \ + -X 'main.buildDate=$$(date -u '+%Y-%m-%d %H:%M:%S UTC')'" \ -o $(BUILD_DIR)/linux-arm/openmcpauthproxy $(PROJECT_ROOT)/cmd/proxy cp config.yaml $(BUILD_DIR)/linux-arm build-darwin: mkdir -p $(BUILD_DIR)/darwin GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -x -ldflags "-X main.version=$(BUILD_VERSION) \ + -X 'main.buildDate=$$(date -u '+%Y-%m-%d %H:%M:%S UTC')'" \ -o $(BUILD_DIR)/darwin/openmcpauthproxy $(PROJECT_ROOT)/cmd/proxy cp config.yaml $(BUILD_DIR)/darwin From 9ad508f127f4d628f4d01011e15082779637c56f Mon Sep 17 00:00:00 2001 From: Pavindu Lakshan Date: Fri, 18 Apr 2025 11:49:30 +0530 Subject: [PATCH 2/6] Debug release workflow --- .github/scripts/release.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/scripts/release.sh b/.github/scripts/release.sh index 3cc1041..2afe872 100644 --- a/.github/scripts/release.sh +++ b/.github/scripts/release.sh @@ -82,8 +82,13 @@ echo "Creating release packages for version $NEW_VERSION..." # List of supported OSes. oses=("linux" "linux-arm" "darwin") +cd "${BUILD_DIRECTORY}" + +ls -a + # Navigate to the release directory. -cd "${RELEASE_DIRECTORY}" +#cd "${RELEASE_DIRECTORY}" +cd "/releases" for os in "${oses[@]}"; do os_dir="../$os" From b8718bb636537f05c68c21f93f6b25149c2abb60 Mon Sep 17 00:00:00 2001 From: Pavindu Lakshan Date: Fri, 18 Apr 2025 12:25:16 +0530 Subject: [PATCH 3/6] Remove git pull --- .github/scripts/release.sh | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/scripts/release.sh b/.github/scripts/release.sh index 2afe872..9188b94 100644 --- a/.github/scripts/release.sh +++ b/.github/scripts/release.sh @@ -28,26 +28,9 @@ VERSION_TYPE=$3 # possible values: major, minor, patch BUILD_DIRECTORY="$WORK_DIR/build" RELEASE_DIRECTORY="$BUILD_DIRECTORY/releases" -# Configuration variables. -GIT_EMAIL="iam-cloud@wso2.com" -GIT_USERNAME="wso2-iam-cloud-bot" -UPSTREAM_REPO_URL="https://github.com/wso2/open-mcp-auth-proxy.git" -UPSTREAM_BRANCH="main" - -# Configure git. -git config --global user.email "${GIT_EMAIL}" -git config --global user.name "${GIT_USERNAME}" - # Navigate to the working directory. cd "${WORK_DIR}" -# Set 'origin' to point to the upstream repository. -git remote set-url origin "${UPSTREAM_REPO_URL}" - -# Ensure the latest changes are pulled. -git checkout ${UPSTREAM_BRANCH} -git pull - # Create the release directory. if [ ! -d "$RELEASE_DIRECTORY" ]; then mkdir -p "$RELEASE_DIRECTORY" From 0de291fc8724e50521f4125bf54c02c20d571659 Mon Sep 17 00:00:00 2001 From: Pavindu Lakshan Date: Fri, 18 Apr 2025 12:29:10 +0530 Subject: [PATCH 4/6] Fix copy command --- .github/scripts/release.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/scripts/release.sh b/.github/scripts/release.sh index 9188b94..57d2823 100644 --- a/.github/scripts/release.sh +++ b/.github/scripts/release.sh @@ -65,13 +65,8 @@ echo "Creating release packages for version $NEW_VERSION..." # List of supported OSes. oses=("linux" "linux-arm" "darwin") -cd "${BUILD_DIRECTORY}" - -ls -a - # Navigate to the release directory. -#cd "${RELEASE_DIRECTORY}" -cd "/releases" +cd "${RELEASE_DIRECTORY}" for os in "${oses[@]}"; do os_dir="../$os" From 10f87b881d8a13f529f903f899b7e622dc0ebe26 Mon Sep 17 00:00:00 2001 From: Pavindu Lakshan Date: Fri, 18 Apr 2025 13:36:13 +0530 Subject: [PATCH 5/6] Configure the release to be triggered on workflow dispatch only --- .github/scripts/release.sh | 18 ++++++++++++++++++ .github/workflows/release.yml | 3 --- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/scripts/release.sh b/.github/scripts/release.sh index 57d2823..ebffc94 100644 --- a/.github/scripts/release.sh +++ b/.github/scripts/release.sh @@ -25,6 +25,24 @@ GIT_TOKEN=$1 WORK_DIR=$2 VERSION_TYPE=$3 # possible values: major, minor, patch + Check if GIT_TOKEN is empty +if [ -z "$GIT_TOKEN" ]; then + echo "❌ Error: GIT_TOKEN is not set." + exit 1 +fi + +# Check if WORK_DIR is empty +if [ -z "$WORK_DIR" ]; then + echo "❌ Error: WORK_DIR is not set." + exit 1 +fi + +# Validate VERSION_TYPE +if [[ "$VERSION_TYPE" != "major" && "$VERSION_TYPE" != "minor" && "$VERSION_TYPE" != "patch" ]]; then + echo "❌ Error: VERSION_TYPE must be one of: major, minor, or patch." + exit 1 +fi + BUILD_DIRECTORY="$WORK_DIR/build" RELEASE_DIRECTORY="$BUILD_DIRECTORY/releases" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 63e56b6..e55f6b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,9 +10,6 @@ name: Release on: - pull_request: - branches: [ main ] - types: [closed] workflow_dispatch: inputs: version_type: From 0f9a8716a80c2cf59738a66232f1ecbc3583efad Mon Sep 17 00:00:00 2001 From: Pavindu Lakshan Date: Fri, 18 Apr 2025 15:10:46 +0530 Subject: [PATCH 6/6] Fix verbose logs --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index 1a8495b..c9ef883 100644 --- a/Makefile +++ b/Makefile @@ -31,21 +31,18 @@ build: clean test build-linux build-linux-arm build-darwin build-linux: mkdir -p $(BUILD_DIR)/linux GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -x -ldflags "-X main.version=$(BUILD_VERSION) \ - -X 'main.buildDate=$$(date -u '+%Y-%m-%d %H:%M:%S UTC')'" \ -o $(BUILD_DIR)/linux/openmcpauthproxy $(PROJECT_ROOT)/cmd/proxy cp config.yaml $(BUILD_DIR)/linux build-linux-arm: mkdir -p $(BUILD_DIR)/linux-arm GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -x -ldflags "-X main.version=$(BUILD_VERSION) \ - -X 'main.buildDate=$$(date -u '+%Y-%m-%d %H:%M:%S UTC')'" \ -o $(BUILD_DIR)/linux-arm/openmcpauthproxy $(PROJECT_ROOT)/cmd/proxy cp config.yaml $(BUILD_DIR)/linux-arm build-darwin: mkdir -p $(BUILD_DIR)/darwin GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -x -ldflags "-X main.version=$(BUILD_VERSION) \ - -X 'main.buildDate=$$(date -u '+%Y-%m-%d %H:%M:%S UTC')'" \ -o $(BUILD_DIR)/darwin/openmcpauthproxy $(PROJECT_ROOT)/cmd/proxy cp config.yaml $(BUILD_DIR)/darwin