|
| 1 | +name: Build and Publish Compute Releases |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + |
| 12 | + build: |
| 13 | + runs-on: ${{ matrix.runner }} |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + include: |
| 17 | + - { runner: macos-latest, osname: macOS, arch: amd64, target: x86_64-apple-darwin, command: build } |
| 18 | + - { runner: macos-latest, osname: macOS, arch: arm64, target: aarch64-apple-darwin, command: build } |
| 19 | + - { runner: ubuntu-latest, osname: linux, arch: amd64, target: x86_64-unknown-linux-gnu, command: build } |
| 20 | + - { runner: ubuntu-latest, osname: linux, arch: arm64, target: aarch64-unknown-linux-gnu, command: build, build_args: --no-default-features } |
| 21 | + - { runner: windows-latest, osname: windows, arch: amd64, target: x86_64-pc-windows-msvc, command: build, extension: ".exe" } |
| 22 | + # - { runner: windows-latest, osname: windows, arch: arm64, target: aarch64-pc-windows-msvc, command: build, extension: ".exe", toolchain: nightly } |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout code |
| 26 | + uses: actions/checkout@v3 |
| 27 | + |
| 28 | + - name: Get the release version from the tag |
| 29 | + shell: bash |
| 30 | + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV |
| 31 | + |
| 32 | + - name: Build binary |
| 33 | + uses: houseabsolute/actions-rust-cross@v0 |
| 34 | + with: |
| 35 | + command: ${{ matrix.command }} |
| 36 | + target: ${{ matrix.target }} |
| 37 | + args: "--locked --release ${{ matrix.build_args }}" |
| 38 | + strip: true |
| 39 | + |
| 40 | + - name: Prepare Release File |
| 41 | + run: | |
| 42 | + # move the binary |
| 43 | + mv target/${{ matrix.target }}/release/dkn-compute${{ matrix.extension }} ./dkn-compute-binary-${{ matrix.osname }}-${{ matrix.arch }}${{ matrix.extension }} |
| 44 | + |
| 45 | +
|
| 46 | + - name: Upload Launch Artifacts |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + with: |
| 49 | + name: dkn-compute-binary-${{ matrix.osname }}-${{ matrix.arch }} |
| 50 | + path: dkn-compute-binary-${{ matrix.osname }}-${{ matrix.arch }}${{ matrix.extension }} |
| 51 | + |
| 52 | + |
| 53 | + release: |
| 54 | + needs: build |
| 55 | + runs-on: ubuntu-latest |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Checkout code |
| 59 | + uses: actions/checkout@v3 |
| 60 | + with: |
| 61 | + fetch-depth: 0 # Fetch all tags and history |
| 62 | + |
| 63 | + - name: Download Launch Artifacts |
| 64 | + uses: actions/download-artifact@v4 |
| 65 | + with: |
| 66 | + merge-multiple: true |
| 67 | + path: ./artifacts |
| 68 | + |
| 69 | + - name: Get the latest tag |
| 70 | + id: get_latest_tag |
| 71 | + run: | |
| 72 | + # latest release tag |
| 73 | + LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "untagged") |
| 74 | + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV |
| 75 | +
|
| 76 | + # latest release name |
| 77 | + LATEST_RELEASE=$(curl -s \ |
| 78 | + -H "Accept: application/vnd.github.v3+json" \ |
| 79 | + https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.name // "no-release-found"') |
| 80 | + echo "LATEST_RELEASE=$LATEST_RELEASE" >> $GITHUB_ENV |
| 81 | + |
| 82 | + echo "Latest Tag: $LATEST_TAG" |
| 83 | + echo "Latest Release: $LATEST_RELEASE" |
| 84 | +
|
| 85 | + - name: Create release with artifacts |
| 86 | + uses: ncipollo/release-action@v1 |
| 87 | + with: |
| 88 | + name: ${{ env.LATEST_RELEASE }} |
| 89 | + tag: ${{ env.LATEST_TAG }} |
| 90 | + artifacts: "artifacts/*" |
| 91 | + artifactContentType: application/octet-stream |
| 92 | + allowUpdates: true |
| 93 | + # draft: true |
0 commit comments