|
| 1 | +name: Datadog Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - v* |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + |
| 12 | +jobs: |
| 13 | + nydus-linux: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + arch: [amd64, arm64] |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + - name: Setup rust toolchain |
| 21 | + run: rustup show |
| 22 | + - name: Read Rust toolchain version |
| 23 | + id: set_toolchain_version |
| 24 | + run: | |
| 25 | + RUST_TOOLCHAIN_VERSION=$(grep -oP '(?<=channel = ")[^"]*' rust-toolchain.toml) |
| 26 | + echo "Rust toolchain version: $RUST_TOOLCHAIN_VERSION" |
| 27 | + echo "rust-version=$RUST_TOOLCHAIN_VERSION" >> $GITHUB_OUTPUT |
| 28 | + shell: bash |
| 29 | + - name: Build nydus-rs Non-RISC-V |
| 30 | + if: matrix.arch != 'riscv64' |
| 31 | + run: | |
| 32 | + declare -A rust_target_map=( ["amd64"]="x86_64-unknown-linux-musl" ["arm64"]="aarch64-unknown-linux-musl") |
| 33 | + RUST_TARGET=${rust_target_map[${{ matrix.arch }}]} |
| 34 | + cargo install --locked --version 0.2.5 cross |
| 35 | + make -e RUST_TARGET_STATIC=$RUST_TARGET -e CARGO=cross static-release |
| 36 | + - name: Prepare to upload artifacts |
| 37 | + run: | |
| 38 | + declare -A rust_target_map=( ["amd64"]="x86_64-unknown-linux-musl" ["arm64"]="aarch64-unknown-linux-musl") |
| 39 | + RUST_TARGET=${rust_target_map[${{ matrix.arch }}]} |
| 40 | + sudo mv target/$RUST_TARGET/release/nydusd nydusd |
| 41 | + sudo mv target/$RUST_TARGET/release/nydus-image . |
| 42 | + sudo mv target/$RUST_TARGET/release/nydusctl . |
| 43 | + sudo cp -r misc/configs . |
| 44 | + sudo chown -R $(id -un):$(id -gn) . ~/.cargo/ |
| 45 | + - name: store-artifacts |
| 46 | + uses: actions/upload-artifact@v4 |
| 47 | + with: |
| 48 | + name: nydus-artifacts-linux-${{ matrix.arch }} |
| 49 | + path: | |
| 50 | + nydusd |
| 51 | + nydus-image |
| 52 | + nydusctl |
| 53 | + configs |
| 54 | +
|
| 55 | + contrib-linux: |
| 56 | + runs-on: ubuntu-latest |
| 57 | + strategy: |
| 58 | + matrix: |
| 59 | + arch: [amd64, arm64] |
| 60 | + env: |
| 61 | + DOCKER: false |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v4 |
| 64 | + - name: Setup Golang |
| 65 | + uses: actions/setup-go@v5 |
| 66 | + with: |
| 67 | + go-version-file: 'go.work' |
| 68 | + cache-dependency-path: "**/*.sum" |
| 69 | + - name: build contrib go components |
| 70 | + run: | |
| 71 | + make -e GOARCH=${{ matrix.arch }} contrib-release |
| 72 | + sudo mv contrib/nydusify/cmd/nydusify . |
| 73 | + sudo mv contrib/nydus-overlayfs/bin/nydus-overlayfs . |
| 74 | + - name: store-artifacts |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: nydus-artifacts-linux-${{ matrix.arch }}-contrib |
| 78 | + path: | |
| 79 | + nydusify |
| 80 | + nydus-overlayfs |
| 81 | + containerd-nydus-grpc |
| 82 | +
|
| 83 | + prepare-tarball-linux: |
| 84 | + runs-on: ubuntu-latest |
| 85 | + strategy: |
| 86 | + matrix: |
| 87 | + arch: [amd64, arm64] |
| 88 | + os: [linux] |
| 89 | + needs: [nydus-linux, contrib-linux] |
| 90 | + steps: |
| 91 | + - name: download artifacts |
| 92 | + uses: actions/download-artifact@v4 |
| 93 | + with: |
| 94 | + pattern: nydus-artifacts-${{ matrix.os }}-${{ matrix.arch }}* |
| 95 | + merge-multiple: true |
| 96 | + path: nydus-static |
| 97 | + - name: prepare release tarball |
| 98 | + run: | |
| 99 | + tag=$(echo $GITHUB_REF | cut -d/ -f3-) |
| 100 | + tarball="nydus-static-$tag-${{ matrix.os }}-${{ matrix.arch }}.tgz" |
| 101 | + chmod +x nydus-static/* |
| 102 | + tar cf - nydus-static | gzip > ${tarball} |
| 103 | + echo "tarball=${tarball}" >> $GITHUB_ENV |
| 104 | +
|
| 105 | + shasum="$tarball.sha256sum" |
| 106 | + sha256sum $tarball > $shasum |
| 107 | + echo "tarball_shasum=${shasum}" >> $GITHUB_ENV |
| 108 | + - name: store-artifacts |
| 109 | + uses: actions/upload-artifact@v4 |
| 110 | + with: |
| 111 | + name: nydus-release-tarball-${{ matrix.os }}-${{ matrix.arch }} |
| 112 | + path: | |
| 113 | + ${{ env.tarball }} |
| 114 | + ${{ env.tarball_shasum }} |
| 115 | +
|
| 116 | + create-release: |
| 117 | + runs-on: ubuntu-latest |
| 118 | + needs: [prepare-tarball-linux] |
| 119 | + permissions: |
| 120 | + contents: write |
| 121 | + steps: |
| 122 | + - name: download artifacts |
| 123 | + uses: actions/download-artifact@v4 |
| 124 | + with: |
| 125 | + pattern: nydus-release-tarball-* |
| 126 | + merge-multiple: true |
| 127 | + path: nydus-tarball |
| 128 | + - name: prepare release env |
| 129 | + run: | |
| 130 | + echo "tarballs<<EOF" >> $GITHUB_ENV |
| 131 | + for I in $(ls nydus-tarball);do echo "nydus-tarball/${I}" >> $GITHUB_ENV; done |
| 132 | + echo "EOF" >> $GITHUB_ENV |
| 133 | + tag=$(echo $GITHUB_REF | cut -d/ -f3-) |
| 134 | + echo "tag=${tag}" >> $GITHUB_ENV |
| 135 | + cat $GITHUB_ENV |
| 136 | + - name: push release |
| 137 | + if: github.event_name == 'push' |
| 138 | + uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 |
| 139 | + with: |
| 140 | + name: "Nydus Image Service ${{ env.tag }}" |
| 141 | + body: | |
| 142 | + New release for Datadog use. |
| 143 | + generate_release_notes: true |
| 144 | + files: | |
| 145 | + ${{ env.tarballs }} |
| 146 | +
|
| 147 | + goreleaser: |
| 148 | + strategy: |
| 149 | + matrix: |
| 150 | + arch: [amd64, arm64] |
| 151 | + os: [linux] |
| 152 | + needs: [nydus-linux, contrib-linux] |
| 153 | + permissions: |
| 154 | + contents: write |
| 155 | + runs-on: ubuntu-latest |
| 156 | + timeout-minutes: 60 |
| 157 | + outputs: |
| 158 | + hashes: ${{ steps.hash.outputs.hashes }} |
| 159 | + steps: |
| 160 | + - name: Checkout |
| 161 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
| 162 | + with: |
| 163 | + fetch-depth: 0 |
| 164 | + submodules: recursive |
| 165 | + |
| 166 | + - name: Setup Golang |
| 167 | + uses: actions/setup-go@v5 |
| 168 | + with: |
| 169 | + go-version-file: 'go.work' |
| 170 | + cache-dependency-path: "**/*.sum" |
| 171 | + - name: download artifacts |
| 172 | + uses: actions/download-artifact@v4 |
| 173 | + with: |
| 174 | + pattern: nydus-artifacts-${{ matrix.os }}-${{ matrix.arch }}* |
| 175 | + merge-multiple: true |
| 176 | + path: nydus-static |
| 177 | + - name: prepare context |
| 178 | + run: | |
| 179 | + chmod +x nydus-static/* |
| 180 | + export GOARCH=${{ matrix.arch }} |
| 181 | + echo "GOARCH: $GOARCH" |
| 182 | + sh ./goreleaser.sh |
| 183 | + - name: Check GoReleaser config |
| 184 | + uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3 |
| 185 | + with: |
| 186 | + version: latest |
| 187 | + args: check |
| 188 | + |
| 189 | + - name: Run GoReleaser |
| 190 | + uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3 |
| 191 | + id: run-goreleaser |
| 192 | + with: |
| 193 | + version: latest |
| 194 | + args: release --clean |
| 195 | + env: |
| 196 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 197 | + |
| 198 | + - name: Generate subject |
| 199 | + id: hash |
| 200 | + env: |
| 201 | + ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}" |
| 202 | + run: | |
| 203 | + set -euo pipefail |
| 204 | + hashes=$(echo $ARTIFACTS | jq --raw-output '.[] | {name, "digest": (.extra.Digest // .extra.Checksum)} | select(.digest) | {digest} + {name} | join(" ") | sub("^sha256:";"")' | base64 -w0) |
| 205 | + if test "$hashes" = ""; then # goreleaser < v1.13.0 |
| 206 | + checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path') |
| 207 | + hashes=$(cat $checksum_file | base64 -w0) |
| 208 | + fi |
| 209 | + echo "hashes=$hashes" >> $GITHUB_OUTPUT |
| 210 | +
|
| 211 | + - name: Set tag output |
| 212 | + id: tag |
| 213 | + run: echo "tag_name=${GITHUB_REF#refs/*/}" >> "$GITHUB_OUTPUT" |
0 commit comments