Add release workflow
This commit is contained in:
parent
5261a69f7a
commit
92db9f5d13
3 changed files with 29 additions and 18 deletions
41
.github/scripts/release.sh
vendored
41
.github/scripts/release.sh
vendored
|
@ -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 <GITHUB_TOKEN> <WORK_DIR>" >&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"
|
||||
|
|
3
.github/workflows/release.yml
vendored
3
.github/workflows/release.yml
vendored
|
@ -10,6 +10,9 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
types: [closed]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version_type:
|
||||
|
|
3
Makefile
3
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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue