From 4a106932981f4075ddadab3f02221c1934feeed3 Mon Sep 17 00:00:00 2001 From: phoenixit99 Date: Thu, 23 Jan 2025 18:36:33 +0700 Subject: [PATCH 1/2] CI Pipeline Integration for Platform-Specific Release Files from ZIP Extraction #59 --- .github/workflows/release.yml | 49 +++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6deadfc..ce5e6c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,11 @@ name: Desktop Release Build +# Add environment variables at the top level +env: + LINUX_ASSETS_URL: "https://github.com/pactus-project/pactus/releases/download/v1.6.4/pactus-cli_1.6.4_linux_amd64.tar.gz" + WINDOWS_ASSETS_URL: "https://github.com/pactus-project/pactus/releases/download/v1.6.4/pactus-cli_1.6.4_windows_amd64.zip" + MACOS_ASSETS_URL: "https://github.com/pactus-project/pactus/releases/download/v1.6.4/pactus-cli_1.6.4_darwin_arm64.tar.gz" + permissions: contents: write pull-requests: read @@ -34,22 +40,28 @@ jobs: sudo apt-get install -y cmake pkg-config sudo apt-get install -y libblkid-dev sudo apt-get install -y liblzma-dev + sudo apt-get install -y unzip - name: Enable Linux desktop run: flutter config --enable-linux-desktop - name: Get dependencies - run: flutter pub get + run: flutter pub get + + - name: Fetch and Extract File + run: | + curl -L -o file.tar.gz ${{ env.LINUX_ASSETS_URL }} + mkdir -p lib/src/core/common/files/ + tar -xzf file.tar.gz -C lib/src/core/common/files/ - name: Build application run: flutter build linux --release - name: Archive Release - uses: thedoctor0/zip-release@master - with: - type: 'zip' - filename: 'linux-build.zip' - directory: build/linux/x64/release/bundle + run: | + cp -r $GITHUB_WORKSPACE/lib/src/core/common/files/* build/linux/x64/release/bundle/ + cd build/linux/x64/release/bundle + zip -r linux-build.zip ./* - name: Create Linux Release id: create_linux_release @@ -135,6 +147,13 @@ jobs: - name: Get dependencies run: flutter pub get + - name: Fetch and Extract File + shell: pwsh + run: | + New-Item -Path "$GITHUB_WORKSPACE/lib/src/core/common/files" -ItemType Directory -Force + Invoke-WebRequest -Uri ${{ env.WINDOWS_ASSETS_URL }} -OutFile "file.zip" + Expand-Archive -Path "file.zip" -DestinationPath "$GITHUB_WORKSPACE/lib/src/core/common/files" -Force + - name: Build application run: | flutter doctor -v @@ -152,10 +171,11 @@ jobs: } - name: Archive Release - shell: bash + shell: pwsh run: | cd build/windows/x64/runner/Release - 7z a -tzip windows-build.zip ./* + Copy-Item -Path "$GITHUB_WORKSPACE/lib/src/core/common/files/*" -Destination "." -Recurse -Force + Compress-Archive -Path * -DestinationPath windows-build.zip -Force - name: Create Windows Release id: create_windows_release @@ -208,7 +228,7 @@ jobs: args: | 🚀 **Windows Release Published!** - 📦 Version: Windows Release ${{ github.run_number }} + 📦 Version: Windows Release ${{ github.run_number }} 🔄 PR: #${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }} 👤 Requested by: ${{ github.event.pull_request.user.login }} ✅ Merged by: ${{ github.event.pull_request.merged_by.login }} @@ -241,6 +261,12 @@ jobs: - name: Get dependencies run: flutter pub get + - name: Fetch and Extract File + run: | + mkdir -p lib/src/core/common/files/ + curl -L -o file.tar.gz ${{ env.MACOS_ASSETS_URL }} + tar -xzf file.tar.gz -C lib/src/core/common/files/ + - name: Build application run: | flutter doctor -v @@ -260,7 +286,8 @@ jobs: - name: Archive Release run: | cd build/macos/Build/Products/Release - zip -r macos-build.zip *.app + cp -r $GITHUB_WORKSPACE/lib/src/core/common/files/* . + zip -r macos-build.zip ./* - name: Create macOS Release id: create_macos_release @@ -321,4 +348,4 @@ jobs: 📥 *Download Link:* [macOS Build](https://github.com/${{ github.repository }}/releases/download/macos-release-${{ github.run_number }}/macos-build.zip) - 🔍 [View Release](https://github.com/${{ github.repository }}/releases/tag/macos-release-${{ github.run_number }}) + 🔍 [View Release](https://github.com/${{ github.repository }}/releases/tag/macos-release-${{ github.run_number }}) \ No newline at end of file From 0d14200e089bc764ab40e387aa5f3e83d8c3c1cf Mon Sep 17 00:00:00 2001 From: Hoang Nguyen Date: Mon, 3 Feb 2025 17:47:59 +0700 Subject: [PATCH 2/2] update: add bash script to support run locally --- local_build.sh | 131 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100755 local_build.sh diff --git a/local_build.sh b/local_build.sh new file mode 100755 index 0000000..8432174 --- /dev/null +++ b/local_build.sh @@ -0,0 +1,131 @@ +#!/bin/bash + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Version variables +PACTUS_VERSION="1.6.4" +BUILD_NUMBER="local001" + +# Asset URLs +LINUX_ASSETS_URL="https://github.com/pactus-project/pactus/releases/download/v${PACTUS_VERSION}/pactus-cli_${PACTUS_VERSION}_linux_amd64.tar.gz" +WINDOWS_ASSETS_URL="https://github.com/pactus-project/pactus/releases/download/v${PACTUS_VERSION}/pactus-cli_${PACTUS_VERSION}_windows_amd64.zip" +MACOS_ASSETS_URL="https://github.com/pactus-project/pactus/releases/download/v${PACTUS_VERSION}/pactus-cli_${PACTUS_VERSION}_darwin_arm64.tar.gz" + +# Function to check if a command exists +check_command() { + if ! command -v $1 &> /dev/null; then + echo -e "${RED}Error: $1 is not installed${NC}" + exit 1 + fi +} + +# Function to build for Linux +build_linux() { + echo -e "${BLUE}Building for Linux...${NC}" + + # Create directory for assets + mkdir -p lib/src/core/common/files/ + + # Download and extract Pactus CLI + curl -L -o file.tar.gz $LINUX_ASSETS_URL + tar -xzf file.tar.gz -C lib/src/core/common/files/ + rm file.tar.gz + + # Build Flutter application + flutter config --enable-linux-desktop + flutter build linux --release + + # Package the build + cd build/linux/x64/release/bundle + cp -r ../../../../lib/src/core/common/files/* . + zip -r linux-build-${BUILD_NUMBER}.zip ./* + + echo -e "${GREEN}Linux build completed: build/linux/x64/release/bundle/linux-build-${BUILD_NUMBER}.zip${NC}" +} + +# Function to build for macOS +build_macos() { + echo -e "${BLUE}Building for macOS...${NC}" + + # Create directory for assets + mkdir -p lib/src/core/common/files/ + + # Download and extract Pactus CLI + curl -L -o file.tar.gz $MACOS_ASSETS_URL + tar -xzf file.tar.gz -C lib/src/core/common/files/ + rm file.tar.gz + + # Build Flutter application + flutter config --enable-macos-desktop + flutter build macos --release + + # Package the build + cd build/macos/Build/Products/Release + cp -r ../../../../../lib/src/core/common/files/* . + zip -r macos-build-${BUILD_NUMBER}.zip ./* + + echo -e "${GREEN}macOS build completed: build/macos/Build/Products/Release/macos-build-${BUILD_NUMBER}.zip${NC}" +} + +# Function to build for Windows +build_windows() { + echo -e "${BLUE}Building for Windows...${NC}" + + # Create directory for assets + mkdir -p lib/src/core/common/files/ + + # Download and extract Pactus CLI + curl -L -o file.zip $WINDOWS_ASSETS_URL + unzip file.zip -d lib/src/core/common/files/ + rm file.zip + + # Build Flutter application + flutter config --enable-windows-desktop + flutter build windows --release + + # Package the build + cd build/windows/x64/runner/Release + cp -r ../../../../../lib/src/core/common/files/* . + zip -r windows-build-${BUILD_NUMBER}.zip ./* + + echo -e "${GREEN}Windows build completed: build/windows/x64/runner/Release/windows-build-${BUILD_NUMBER}.zip${NC}" +} + +# Check required tools +check_command "flutter" +check_command "curl" +check_command "zip" +check_command "unzip" + +# Clean previous builds +echo -e "${BLUE}Cleaning previous builds...${NC}" +flutter clean + +# Get Flutter dependencies +echo -e "${BLUE}Getting Flutter dependencies...${NC}" +flutter pub get + +flutter gen-l10n + +# Detect operating system and build accordingly +case "$(uname -s)" in + Linux*) + build_linux + ;; + Darwin*) + build_macos + ;; + MINGW*|MSYS*|CYGWIN*) + build_windows + ;; + *) + echo -e "${RED}Unsupported operating system${NC}" + exit 1 + ;; +esac + +echo -e "${GREEN}Build process completed successfully!${NC}" \ No newline at end of file