From 54329c71a0315931916c3403ae4a8f12d20947cc Mon Sep 17 00:00:00 2001 From: Matee Ullah Malik Date: Wed, 13 Aug 2025 17:08:40 +0500 Subject: [PATCH 1/2] Refactor build and release workflow --- .github/workflows/build&release.yml | 106 ++-------------------------- .github/workflows/tests.yml | 28 ++++---- 2 files changed, 19 insertions(+), 115 deletions(-) diff --git a/.github/workflows/build&release.yml b/.github/workflows/build&release.yml index 8cd6d661..72517513 100644 --- a/.github/workflows/build&release.yml +++ b/.github/workflows/build&release.yml @@ -17,84 +17,8 @@ permissions: packages: read jobs: - build: - runs-on: ubuntu-22.04 - timeout-minutes: 30 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Configure Git Safe Directory - run: git config --global --add safe.directory $GITHUB_WORKSPACE - - - name: Setup Go and dependencies - uses: ./.github/actions/setup-env - - - name: Prepare Build Variables - id: vars - run: | - # Prepare version information - VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev") - GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") - BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S') - - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "git_commit=$GIT_COMMIT" >> $GITHUB_OUTPUT - echo "build_time=$BUILD_TIME" >> $GITHUB_OUTPUT - echo "binary_name=supernode-linux-amd64" >> $GITHUB_OUTPUT - - - name: Build binaries - run: | - mkdir -p release - - # Build supernode - CGO_ENABLED=1 \ - GOOS=linux \ - GOARCH=amd64 \ - go build \ - -trimpath \ - -ldflags="-s -w \ - -X github.com/LumeraProtocol/supernode/supernode/cmd.Version=${{ steps.vars.outputs.version }} \ - -X github.com/LumeraProtocol/supernode/supernode/cmd.GitCommit=${{ steps.vars.outputs.git_commit }} \ - -X github.com/LumeraProtocol/supernode/supernode/cmd.BuildTime=${{ steps.vars.outputs.build_time }}" \ - -o release/supernode \ - ./supernode - - # Build sn-manager - cd sn-manager - CGO_ENABLED=0 \ - GOOS=linux \ - GOARCH=amd64 \ - go build \ - -trimpath \ - -ldflags="-s -w \ - -X main.Version=${{ steps.vars.outputs.version }} \ - -X main.GitCommit=${{ steps.vars.outputs.git_commit }} \ - -X main.BuildTime=${{ steps.vars.outputs.build_time }}" \ - -o ../release/sn-manager \ - . - cd .. - - chmod +x release/supernode release/sn-manager - - # Create tarball - cd release - tar -czf ${{ steps.vars.outputs.binary_name }}.tar.gz supernode sn-manager - cd .. - - cp release/supernode release/${{ steps.vars.outputs.binary_name }} - - - name: Fix Release Directory Permissions - run: | - sudo chown -R $USER:$USER release/ - sudo chmod -R 755 release/ - release: - needs: build - if: startsWith(github.ref, 'refs/tags/v') && (github.ref_type == 'tag') && (contains(github.ref, '.') && (contains(github.ref, 'v'))) + if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-22.04 timeout-minutes: 15 @@ -119,9 +43,6 @@ jobs: TAG_MESSAGE="${TAG_MESSAGE//$'\r'/'%0D'}" echo "tag_message=$TAG_MESSAGE" >> $GITHUB_OUTPUT - - name: Configure Git Safe Directory - run: git config --global --add safe.directory $GITHUB_WORKSPACE - - name: Setup Go and dependencies uses: ./.github/actions/setup-env @@ -129,7 +50,7 @@ jobs: id: vars run: | VERSION=${{ steps.tag_info.outputs.tag_name }} - GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") + GIT_COMMIT=$(git rev-parse --short HEAD) BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S') echo "version=$VERSION" >> $GITHUB_OUTPUT @@ -178,17 +99,14 @@ jobs: cp release/supernode release/${{ steps.vars.outputs.binary_name }} - - name: Fix Release Directory Permissions - run: | - sudo chown -R $USER:$USER release/ - sudo chmod -R 755 release/ - - name: Publish the Release uses: softprops/action-gh-release@v0.1.15 if: success() with: tag_name: ${{ steps.tag_info.outputs.tag_name }} - files: release/* + files: | + release/${{ steps.vars.outputs.binary_name }}.tar.gz + release/${{ steps.vars.outputs.binary_name }} generate_release_notes: true body: | ${{ steps.tag_info.outputs.tag_message }} @@ -196,18 +114,4 @@ jobs: Version: ${{ steps.vars.outputs.version }} Git Commit: ${{ steps.vars.outputs.git_commit }} Build Time: ${{ steps.vars.outputs.build_time }} - - ## Installation - - ### Option 1: Download the tarball (includes both binaries) - 1. Download: `supernode-linux-amd64.tar.gz` - 2. Extract: `tar -xzf supernode-linux-amd64.tar.gz` - 3. Make executable: `chmod +x supernode sn-manager` - 4. Run supernode: `./supernode` - 5. Run sn-manager: `./sn-manager` - - ### Option 2: Download supernode binary only - 1. Download: `supernode-linux-amd64` - 2. Make executable: `chmod +x supernode-linux-amd64` - 3. Run: `./supernode-linux-amd64` token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 25da33dc..bad0f6ee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -56,23 +56,23 @@ jobs: - name: Run cascade e2e tests run: make test-cascade - sn-manager-e2e-tests: - name: sn-manager-e2e-tests - runs-on: ubuntu-latest + # sn-manager-e2e-tests: + # name: sn-manager-e2e-tests + # runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 - - name: Setup Go and system deps - uses: ./.github/actions/setup-env + # - name: Setup Go and system deps + # uses: ./.github/actions/setup-env - - name: Install Lumera - run: make install-lumera + # - name: Install Lumera + # run: make install-lumera - - name: Setup Supernode environments - run: make setup-supernodes + # - name: Setup Supernode environments + # run: make setup-supernodes - # - name: Run sn-manager e2e tests - # run: make test-sn-manager \ No newline at end of file + # - name: Run sn-manager e2e tests + # run: make test-sn-manager \ No newline at end of file From ac3bc5c163fd091d646ae13b8c7bcd2151617c3e Mon Sep 17 00:00:00 2001 From: Matee Ullah Malik Date: Wed, 13 Aug 2025 17:26:34 +0500 Subject: [PATCH 2/2] Add build job to GitHub Actions workflow for supernode and sn-manager --- .github/workflows/build&release.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/build&release.yml b/.github/workflows/build&release.yml index 72517513..ce237ecd 100644 --- a/.github/workflows/build&release.yml +++ b/.github/workflows/build&release.yml @@ -17,6 +17,28 @@ permissions: packages: read jobs: + build: + runs-on: ubuntu-22.04 + timeout-minutes: 10 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Go and dependencies + uses: ./.github/actions/setup-env + + - name: Build binaries + run: | + # Build supernode + CGO_ENABLED=1 go build -trimpath -o /tmp/supernode ./supernode + + # Build sn-manager + cd sn-manager + CGO_ENABLED=0 go build -trimpath -o /tmp/sn-manager . + + echo "✅ Build successful" + release: if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-22.04