|
| 1 | +# adapted from https://github.com/taiki-e/cargo-hack/blob/main/.github/workflows/release.yml |
| 2 | + |
| 3 | +name: Publish test releases to GitHub |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - "*" |
| 8 | + |
| 9 | +jobs: |
| 10 | + internal-test-release: |
| 11 | + if: github.repository_owner == 'nextest-rs' && startsWith(github.ref_name, 'internal-test-') |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 15 | + with: |
| 16 | + persist-credentials: false |
| 17 | + # Note: do not publish this until binaries are built and uploaded below. This is so that |
| 18 | + # `cargo binstall` keeps working. |
| 19 | + - uses: taiki-e/create-gh-release-action@26b80501670402f1999aff4b934e1574ef2d3705 # v1 |
| 20 | + id: create-gh-release |
| 21 | + with: |
| 22 | + prefix: internal-test |
| 23 | + title: $prefix $version |
| 24 | + branch: main |
| 25 | + env: |
| 26 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + outputs: |
| 28 | + version: ${{ steps.create-gh-release.outputs.version }} |
| 29 | + |
| 30 | + build-cargo-nextest-binaries: |
| 31 | + name: Build cargo-nextest binaries for ${{ matrix.target }} |
| 32 | + if: github.repository_owner == 'nextest-rs' && startsWith(github.ref_name, 'cargo-nextest-') |
| 33 | + needs: |
| 34 | + - internal-test-release |
| 35 | + strategy: |
| 36 | + matrix: |
| 37 | + include: |
| 38 | + # Native builds |
| 39 | + - target: x86_64-pc-windows-msvc |
| 40 | + os: windows-latest |
| 41 | + build-target: x86_64-pc-windows-msvc |
| 42 | + build-tool: cargo |
| 43 | + dry-run: true |
| 44 | + - target: i686-pc-windows-msvc |
| 45 | + os: windows-latest |
| 46 | + build-target: i686-pc-windows-msvc |
| 47 | + build-tool: cargo |
| 48 | + dry-run: true |
| 49 | + - target: aarch64-pc-windows-msvc |
| 50 | + os: windows-latest |
| 51 | + build-target: aarch64-pc-windows-msvc |
| 52 | + build-tool: cargo |
| 53 | + dry-run: true |
| 54 | + runs-on: ${{ matrix.os }} |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 57 | + - name: Install Rust |
| 58 | + uses: dtolnay/rust-toolchain@stable |
| 59 | + - uses: taiki-e/upload-rust-binary-action@db101489b509ad1c7acce163e118eb36a1650f98 # v1.26.0 |
| 60 | + with: |
| 61 | + bin: internal-test |
| 62 | + # The tag name contains the binary name so just use that. |
| 63 | + archive: $tag-$target |
| 64 | + build-tool: ${{ matrix.build-tool }} |
| 65 | + target: ${{ matrix.build-target }} |
| 66 | + tar: all |
| 67 | + zip: windows |
| 68 | + checksum: b2,sha256 |
| 69 | + # dry-run to not upload the binary to the GitHub release |
| 70 | + dry-run: ${{ matrix.dry-run }} |
| 71 | + dry-run-intended: ${{ matrix.dry-run }} |
| 72 | + env: |
| 73 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + CARGO_PROFILE_RELEASE_LTO: true |
| 75 | + CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1 |
| 76 | + - name: Upload unsigned Windows artifact |
| 77 | + id: upload-unsigned-artifact |
| 78 | + if: endsWith(matrix.target, '-pc-windows-msvc') |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: ${{ matrix.target }}-unsigned |
| 82 | + path: target/${{ matrix.build-target }}/release/internal-test.exe |
| 83 | + - run: mkdir -p target/signed |
| 84 | + - name: Submit signing request |
| 85 | + id: submit-signing-request |
| 86 | + if: endsWith(matrix.target, '-pc-windows-msvc') |
| 87 | + uses: signpath/github-action-submit-signing-request@v1.1 |
| 88 | + with: |
| 89 | + api-token: '${{ secrets.SIGNPATH_API_TOKEN }}' |
| 90 | + organization-id: '34634019-2ee0-4162-830a-72cd1a0cb73f' |
| 91 | + project-slug: 'nextest' |
| 92 | + signing-policy-slug: 'internal-test' |
| 93 | + github-artifact-id: '${{ steps.upload-unsigned-artifact.outputs.artifact-id }}' |
| 94 | + wait-for-completion: true |
| 95 | + output-artifact-directory: 'target/signed' |
| 96 | + - name: Archive and upload Windows artifacts |
| 97 | + id: archive-windows-artifact |
| 98 | + if: endsWith(matrix.target, '-pc-windows-msvc') |
| 99 | + shell: bash |
| 100 | + run: | |
| 101 | + cd target/signed |
| 102 | + unzip ${{ matrix.target }}-unsigned.zip |
| 103 | + tar -czf ${{ github.ref_name }}-${{ matrix.target }}.tar.gz internal-test.exe |
| 104 | + mv ${{ matrix.target }}-unsigned.zip ${{ github.ref_name }}-${{ matrix.target }}.zip |
| 105 | + gh release upload ${{ github.ref }} \ |
| 106 | + ${{ github.ref_name }}-${{ matrix.target }}.tar.gz \ |
| 107 | + ${{ github.ref_name }}-${{ matrix.target }}.zip |
| 108 | + - name: Set archive output variable |
| 109 | + id: archive-output |
| 110 | + shell: bash |
| 111 | + run: | |
| 112 | + if [[ ${{ matrix.target }} == *-pc-windows-msvc ]]; then |
| 113 | + echo "${{ matrix.target }}-tar=${{ github.ref_name }}-${{ matrix.target }}".tar.gz >> $GITHUB_OUTPUT |
| 114 | + echo "${{ matrix.target }}-zip=${{ github.ref_name }}-${{ matrix.target }}".zip >> $GITHUB_OUTPUT |
| 115 | + else |
| 116 | + echo "${{ matrix.target }}-tar=${{ github.ref_name }}-${{ matrix.target }}".tar.gz >> $GITHUB_OUTPUT |
| 117 | + fi |
| 118 | + outputs: |
| 119 | + x86_64-windows-tar: ${{ steps.archive-output.outputs.x86_64-pc-windows-msvc-tar }} |
| 120 | + x86_64-windows-zip: ${{ steps.archive-output.outputs.x86_64-pc-windows-msvc-zip }} |
| 121 | + i686-windows-tar: ${{ steps.archive-output.outputs.i686-pc-windows-msvc-tar }} |
| 122 | + i686-windows-zip: ${{ steps.archive-output.outputs.i686-pc-windows-msvc-zip }} |
| 123 | + aarch64-windows-tar: ${{ steps.archive-output.outputs.aarch64-pc-windows-msvc-tar }} |
| 124 | + aarch64-windows-zip: ${{ steps.archive-output.outputs.aarch64-pc-windows-msvc-zip }} |
0 commit comments