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