Build iperf3 x64 static via cygwin-cmd #17
This file contains 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 iperf3 x64 static via cygwin-cmd | |
on: | |
workflow_dispatch: | |
inputs: | |
source_repo: | |
description: "Define the git repo used for the build" | |
required: true | |
default: "https://github.com/esnet/iperf.git" | |
source_branch: | |
description: "Specify the branch to build" | |
required: true | |
default: "master" | |
artifacts_only: | |
description: "No release - artifacts only" | |
required: true | |
default: false | |
type: boolean | |
skip_rerun: | |
description: "Skip rerun?" | |
required: true | |
default: true | |
type: boolean | |
retries: | |
description: "Number of rerun retries" | |
required: true | |
default: "1" | |
type: choice | |
options: ["1", "2", "3", "4", "5", "6", "7", "8", "9"] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: write-all | |
jobs: | |
build: | |
runs-on: windows-latest | |
outputs: | |
set-tag: ${{ steps.set-tag.outputs.release_tag }} | |
strategy: | |
fail-fast: false | |
matrix: | |
name: [iperf3] | |
build: [basic, openssl] | |
arch: [amd64] | |
include: | |
- build: "basic" | |
filename: "" | |
openssl: "no" | |
- build: "openssl" | |
filename: "openssl-" | |
openssl: "yes" | |
name: ${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.filename }}win.zip | |
env: | |
cygwin_path: "" | |
steps: | |
- run: git config --global core.autocrlf input | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install cygwin-installer.cmd | |
run: .\cygwin-installer.cmd | |
- name: Build static | |
run: .\cygwin\bin\bash.exe -l build.sh "${{ matrix.openssl }}" "${{ env.cygwin_path }}" "${{ inputs.source_repo }}" "${{ inputs.source_branch }}" | |
- name: VirusTotal Scan | |
id: virustotal | |
uses: crazy-max/ghaction-virustotal@v4 | |
with: | |
vt_api_key: ${{ secrets.VT_API_KEY }} | |
files: | | |
${{ matrix.name }}/bin/iperf3.exe | |
${{ matrix.name }}/bin/cygwin1.dll | |
- name: sha256sum ${{ github.event.inputs.distinct_id }} | |
run: | | |
printf '%s' https://www.virustotal.com/gui/file/$(sha256sum ${{ matrix.name }}/bin/iperf3.exe | awk '{print $1}') > ${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.filename }}win.url | |
cat ${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.filename }}win.url | |
- name: Archive build | |
run: Compress-Archive ${{ matrix.name }} ${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.filename }}win.zip | |
- name: Generate artifact attestation ${{ github.event.inputs.distinct_id }} | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-path: | | |
${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.filename }}win.zip | |
${{ matrix.name }}/bin/iperf3.exe | |
${{ matrix.name }}/bin/cygwin1.dll | |
- name: Create tag env | |
run: echo "release_tag=$(Get-Content -Path iperf3_version)" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append | |
- name: Set tag env to output | |
id: set-tag | |
run: echo "release_tag=${{ env.release_tag }}" >> $env:GITHUB_OUTPUT | |
- name: "Release - Create artifacts" | |
if: inputs.artifacts_only == '0' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ matrix.name }}-amd64-${{ matrix.filename }}win" | |
path: | | |
${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.filename }}win.zip | |
${{ matrix.name }}-${{ matrix.arch }}-${{ matrix.filename }}win.url | |
- name: "Dev - Create artifacts" | |
if: inputs.artifacts_only == '1' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ matrix.name }}-amd64-${{ matrix.filename }}win" | |
path: "${{ matrix.name }}" | |
release: | |
name: "Publish iperf3 static release assets" | |
runs-on: ubuntu-latest | |
needs: build | |
if: inputs.artifacts_only == '0' && always() && contains(needs.*.result, 'success') && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: "release-artifacts" | |
pattern: iperf3-amd64-*win | |
merge-multiple: true | |
- name: Virustotal scan results | |
run: | | |
pushd release-artifacts || exit 1 | |
for virus_total_urls in iperf3-*\.url; do | |
dependency_version+=("${virus_total_urls}") | |
done | |
readarray -t release_sorted < <(printf '%s\n' "${dependency_version[@]}" | sort) | |
for filenames in "${release_sorted[@]}"; do | |
virustotal_url="$(head -1 "${filenames}" | tr -d '\r\n')" | |
sed -i -r 's|(\['${filenames//\.url/}'\])\((.*)\)|\1('${virustotal_url}')|' ${{ github.workspace }}/release-body.md | |
done | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Automated Change | |
file_pattern: "release-body.md" | |
- name: "Publish release ${{ needs.build.outputs.set-tag }}" | |
if: inputs.artifacts_only == '0' | |
uses: ncipollo/release-action@v1 | |
with: | |
prerelease: false | |
artifacts: release-artifacts/iperf3-*.zip | |
replacesArtifacts: true | |
tag: ${{ needs.build.outputs.set-tag }} | |
name: iperf3 ${{ needs.build.outputs.set-tag }} | |
allowUpdates: true | |
bodyFile: release-body.md | |
token: ${{ github.token }} | |
rerun-on-failure: | |
if: failure() && inputs.skip_rerun == '0' | |
name: rerun-on-failure | |
needs: [build, release] | |
permissions: | |
actions: write | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: "${{ github.TOKEN }}" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Trigger rerun workflow on job failures | |
run: | | |
inputs_retries="${{ inputs.retries }}" | |
gh workflow run rerun.yml -f run_id=${{ github.run_id }} -f attempts=${{ github.run_attempt }} -f retries=${inputs_retries:-1} |