|
| 1 | +name: Publish nodectl |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "nodectl/v*" |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.sha }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +env: |
| 13 | + WORKING_DIR: src |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-binaries: |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + include: |
| 21 | + - target: x86_64-unknown-linux-gnu |
| 22 | + os: ubuntu-latest |
| 23 | + name: nodectl-linux-amd64 |
| 24 | + - target: aarch64-unknown-linux-gnu |
| 25 | + os: ubuntu-24.04-arm |
| 26 | + name: nodectl-linux-arm64 |
| 27 | + - target: aarch64-apple-darwin |
| 28 | + os: macos-latest |
| 29 | + name: nodectl-darwin-arm64 |
| 30 | + - target: x86_64-pc-windows-msvc |
| 31 | + os: windows-latest |
| 32 | + name: nodectl-windows-amd64.exe |
| 33 | + runs-on: ${{ matrix.os }} |
| 34 | + permissions: |
| 35 | + contents: read |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v5 |
| 38 | + |
| 39 | + - uses: actions-rust-lang/setup-rust-toolchain@v1 |
| 40 | + with: |
| 41 | + target: ${{ matrix.target }} |
| 42 | + |
| 43 | + - name: Install system dependencies (Linux) |
| 44 | + if: runner.os == 'Linux' |
| 45 | + run: | |
| 46 | + sudo apt-get update |
| 47 | + sudo apt-get install -y pkg-config libssl-dev |
| 48 | +
|
| 49 | + - name: Build |
| 50 | + working-directory: ${{ env.WORKING_DIR }} |
| 51 | + run: cargo build --release --package nodectl --target ${{ matrix.target }} |
| 52 | + shell: bash |
| 53 | + |
| 54 | + - name: Rename binary |
| 55 | + run: | |
| 56 | + if [ "${{ runner.os }}" = "Windows" ]; then |
| 57 | + cp src/target/${{ matrix.target }}/release/nodectl.exe ${{ matrix.name }} |
| 58 | + else |
| 59 | + cp src/target/${{ matrix.target }}/release/nodectl ${{ matrix.name }} |
| 60 | + fi |
| 61 | + shell: bash |
| 62 | + |
| 63 | + - uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: ${{ matrix.name }} |
| 66 | + path: ${{ matrix.name }} |
| 67 | + |
| 68 | + container: |
| 69 | + runs-on: ubuntu-latest |
| 70 | + permissions: |
| 71 | + contents: read |
| 72 | + packages: write |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v5 |
| 75 | + |
| 76 | + - uses: docker/setup-buildx-action@v3 |
| 77 | + |
| 78 | + - name: Log in to GHCR |
| 79 | + uses: docker/login-action@v3 |
| 80 | + with: |
| 81 | + registry: ghcr.io |
| 82 | + username: ${{ github.actor }} |
| 83 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + |
| 85 | + - name: Docker meta |
| 86 | + id: meta |
| 87 | + uses: docker/metadata-action@v5 |
| 88 | + with: |
| 89 | + images: ghcr.io/rsquad/ton-rust-node/nodectl |
| 90 | + tags: | |
| 91 | + type=match,pattern=nodectl/(v.*),group=1 |
| 92 | + type=raw,value=latest |
| 93 | + type=sha |
| 94 | +
|
| 95 | + - name: Build and push |
| 96 | + uses: docker/build-push-action@v6 |
| 97 | + with: |
| 98 | + context: ./src |
| 99 | + file: ./src/Dockerfile.nodectl |
| 100 | + push: true |
| 101 | + tags: ${{ steps.meta.outputs.tags }} |
| 102 | + labels: ${{ steps.meta.outputs.labels }} |
| 103 | + cache-from: type=gha |
| 104 | + cache-to: type=gha,mode=max |
| 105 | + |
| 106 | + release: |
| 107 | + needs: [build-binaries, container] |
| 108 | + runs-on: ubuntu-latest |
| 109 | + permissions: |
| 110 | + contents: write |
| 111 | + steps: |
| 112 | + - uses: actions/checkout@v5 |
| 113 | + |
| 114 | + - uses: actions/download-artifact@v4 |
| 115 | + with: |
| 116 | + pattern: nodectl-* |
| 117 | + path: artifacts |
| 118 | + merge-multiple: true |
| 119 | + |
| 120 | + - name: Extract version from tag |
| 121 | + id: version |
| 122 | + run: | |
| 123 | + VERSION="${GITHUB_REF_NAME#nodectl/}" |
| 124 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 125 | +
|
| 126 | + if echo "$VERSION" | grep -qE '(rc|alpha|beta)'; then |
| 127 | + echo "prerelease=true" >> "$GITHUB_OUTPUT" |
| 128 | + else |
| 129 | + echo "prerelease=false" >> "$GITHUB_OUTPUT" |
| 130 | + fi |
| 131 | +
|
| 132 | + - name: Create GitHub Release |
| 133 | + uses: softprops/action-gh-release@v2 |
| 134 | + with: |
| 135 | + name: "nodectl/${{ steps.version.outputs.version }}" |
| 136 | + body: | |
| 137 | + nodectl ${{ steps.version.outputs.version }} |
| 138 | +
|
| 139 | + Image: `ghcr.io/rsquad/ton-rust-node/nodectl:${{ steps.version.outputs.version }}` |
| 140 | + files: artifacts/* |
| 141 | + prerelease: ${{ steps.version.outputs.prerelease }} |
| 142 | + make_latest: false |
| 143 | + draft: ${{ steps.version.outputs.prerelease }} |
| 144 | + |
| 145 | + - name: Publish pre-release |
| 146 | + if: steps.version.outputs.prerelease == 'true' |
| 147 | + env: |
| 148 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 149 | + run: gh release edit "$GITHUB_REF_NAME" --draft=false |
0 commit comments