fix: update windows path in GHA workflow #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Mainnet | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.arch }} | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| matrix: | |
| include: | |
| - arch: x64 | |
| runner: ubuntu-latest | |
| targets: node18-linux-x64,node18-macos-x64,node18-win-x64 | |
| - arch: arm64 | |
| runner: ubuntu-24.04-arm | |
| targets: node18-linux-arm64,node18-macos-arm64,node18-win-arm64 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build TypeScript | |
| run: npm run mainnet:build:src | |
| - name: Install ldid | |
| run: | | |
| arch=$(uname -m) | |
| curl -sL "https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_linux_${arch}" -o /usr/local/bin/ldid | |
| chmod +x /usr/local/bin/ldid | |
| - name: Build binaries | |
| run: npx pkg out/src/main-mainnet.js -t ${{ matrix.targets }} --output bin/edge | |
| - name: Sign macOS binary | |
| run: ldid -S bin/edge-macos | |
| - name: Rename binaries | |
| run: | | |
| cd bin | |
| for f in edge-linux edge-macos edge-win.exe; do | |
| [ -f "$f" ] || continue | |
| case "$f" in | |
| edge-win.exe) mv "$f" "edge-win-${{ matrix.arch }}.exe" ;; | |
| *) mv "$f" "$f-${{ matrix.arch }}" ;; | |
| esac | |
| done | |
| ls -la | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-${{ matrix.arch }} | |
| path: bin/ | |
| deploy: | |
| name: Deploy | |
| needs: build | |
| runs-on: ubuntu-latest | |
| env: | |
| SSH_PORT: ${{ secrets.FILESERVER_SSH_PORT != '' && secrets.FILESERVER_SSH_PORT || '22' }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get version | |
| id: version | |
| run: echo "version=$(node -p 'require("./package.json").version')" >> "$GITHUB_OUTPUT" | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: bin/ | |
| merge-multiple: true | |
| - name: Prepare artifacts | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| declare -A binaries=( | |
| ["linux/x64"]="edge-linux-x64" | |
| ["linux/arm64"]="edge-linux-arm64" | |
| ["macos/x64"]="edge-macos-x64" | |
| ["macos/arm64"]="edge-macos-arm64" | |
| ["windows/x64"]="edge-win-x64.exe" | |
| ["windows/arm64"]="edge-win-arm64.exe" | |
| ) | |
| for combo in "${!binaries[@]}"; do | |
| platform="${combo%%/*}" | |
| arch="${combo##*/}" | |
| binary="${binaries[$combo]}" | |
| bin_name="edge" | |
| if [[ "$platform" == "windows" ]]; then | |
| bin_name="edge.exe" | |
| fi | |
| dir="dist/${platform}/${arch}/${VERSION}" | |
| mkdir -p "$dir" | |
| cp "bin/${binary}" "${dir}/${bin_name}" | |
| sha256sum "${dir}/${bin_name}" | awk '{print $1}' > "${dir}/checksum" | |
| echo "$VERSION" > "${dir}/version" | |
| done | |
| - name: Deploy to fileserver | |
| env: | |
| SSH_KEY: ${{ secrets.FILESERVER_SSH_KEY }} | |
| SSH_HOST: ${{ secrets.FILESERVER_HOST }} | |
| SSH_USER: ${{ secrets.FILESERVER_SSH_USER }} | |
| BASE_PATH: ${{ secrets.FILESERVER_PATH }} | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "$SSH_KEY" > ~/.ssh/deploy_key | |
| chmod 600 ~/.ssh/deploy_key | |
| ssh-keyscan -p "$SSH_PORT" "$SSH_HOST" >> ~/.ssh/known_hosts 2>/dev/null | |
| for platform in linux macos windows; do | |
| for arch in x64 arm64; do | |
| remote_dir="${BASE_PATH}/cli/mainnet/${platform}/${arch}" | |
| ssh -i ~/.ssh/deploy_key -p "$SSH_PORT" -o StrictHostKeyChecking=accept-new \ | |
| "${SSH_USER}@${SSH_HOST}" "mkdir -p ${remote_dir}/${VERSION}" | |
| scp -i ~/.ssh/deploy_key -P "$SSH_PORT" -o StrictHostKeyChecking=accept-new \ | |
| dist/${platform}/${arch}/${VERSION}/* \ | |
| "${SSH_USER}@${SSH_HOST}:${remote_dir}/${VERSION}/" | |
| ssh -i ~/.ssh/deploy_key -p "$SSH_PORT" -o StrictHostKeyChecking=accept-new \ | |
| "${SSH_USER}@${SSH_HOST}" "cd ${remote_dir} && rm -rf latest && cp -r ${VERSION} latest" | |
| done | |
| done | |
| rm -f ~/.ssh/deploy_key |