|
| 1 | +--- |
| 2 | +name: "build" |
| 3 | + |
| 4 | +"on": |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - "main" |
| 8 | + tags: |
| 9 | + - "*" |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - "main" |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: "${{ github.workflow }}-${{ github.ref }}" |
| 16 | + cancel-in-progress: "${{ github.ref != 'refs/heads/main' }}" |
| 17 | + |
| 18 | +env: |
| 19 | + CURL_VERSION: "curl-8_7_1" |
| 20 | + CURL_BASEURL: "https://github.com/curl/curl/archive/refs/tags" |
| 21 | + CURL_TARGZ_SHA256: "0e46c856f517602c347bb5fe5b73174f8ee798bc87f1a97235c95761f75fcc28" |
| 22 | + CURL_ZIP_SHA256: "1522999600630964ADC3130EADA47DC0BE2A71908A36944B7AA78AAD2B1006B7" |
| 23 | + |
| 24 | +jobs: |
| 25 | + BuildMac: |
| 26 | + runs-on: "macos-14" |
| 27 | + |
| 28 | + strategy: |
| 29 | + matrix: |
| 30 | + config: |
| 31 | + - "Release" |
| 32 | + - "Debug" |
| 33 | + |
| 34 | + defaults: |
| 35 | + run: |
| 36 | + shell: "bash" |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: "Get version" |
| 40 | + run: | |
| 41 | + if [[ $GITHUB_REF =~ ^refs/tags/ ]] |
| 42 | + then version="${GITHUB_REF#refs/tags/}" |
| 43 | + else version=main |
| 44 | + fi |
| 45 | + printf "version=%s" "$version" > "$GITHUB_OUTPUT" |
| 46 | + id: "get-version" |
| 47 | + |
| 48 | + - name: "Checkout" |
| 49 | + uses: "actions/checkout@v4" |
| 50 | + |
| 51 | + - name: "Download and extract Curl" |
| 52 | + run: | |
| 53 | + curl -fsSLO "$CURL_BASEURL/$CURL_VERSION.tar.gz" |
| 54 | + echo "$CURL_TARGZ_SHA256 $CURL_VERSION.tar.gz" | shasum -c |
| 55 | + tar -xf "$CURL_VERSION.tar.gz" |
| 56 | +
|
| 57 | + - name: "Run build-macos.sh" |
| 58 | + run: './build-macos.sh ${{ matrix.config }} ${{ steps.get-version.outputs.version }} "curl-$CURL_VERSION"' |
| 59 | + |
| 60 | + - name: "Upload artifacts" |
| 61 | + uses: "actions/upload-artifact@v4" |
| 62 | + with: |
| 63 | + name: "libcurl-macos-${{ matrix.config }}" |
| 64 | + path: "release/*.tar.gz" |
| 65 | + |
| 66 | + BuildWindows: |
| 67 | + runs-on: "windows-2022" |
| 68 | + |
| 69 | + strategy: |
| 70 | + matrix: |
| 71 | + config: |
| 72 | + - "Release" |
| 73 | + - "Debug" |
| 74 | + |
| 75 | + steps: |
| 76 | + - name: "Get version" |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + if [[ $GITHUB_REF =~ ^refs/tags/ ]] |
| 80 | + then version="${GITHUB_REF#refs/tags/}" |
| 81 | + else version=main |
| 82 | + fi |
| 83 | + printf "version=%s" "$version" > "$GITHUB_OUTPUT" |
| 84 | + id: "get-version" |
| 85 | + |
| 86 | + - name: "Checkout" |
| 87 | + uses: "actions/checkout@v4" |
| 88 | + |
| 89 | + - name: "Download and extract Curl" |
| 90 | + run: | |
| 91 | + Invoke-WebRequest -Uri "$Env:CURL_BASEURL/$Env:CURL_VERSION.zip" -OutFile "$Env:CURL_VERSION.zip" |
| 92 | + $hash = Get-FileHash "$Env:CURL_VERSION.zip" -Algorithm SHA256 |
| 93 | + if ( $hash.Hash -ne "$Env:CURL_ZIP_SHA256" ) { |
| 94 | + exit 1 |
| 95 | + } |
| 96 | + Expand-Archive -Path "$Env:CURL_VERSION.zip" -DestinationPath "." |
| 97 | +
|
| 98 | + - name: "Run Build-Windows.ps1" |
| 99 | + run: './Build-Windows.ps1 -Configuration "${{ matrix.config }}" -Version "${{ steps.get-version.outputs.version }}" -CurlDirectory "curl-$Env:CURL_VERSION"' |
| 100 | + |
| 101 | + - name: "Upload artifacts" |
| 102 | + uses: "actions/upload-artifact@v4" |
| 103 | + with: |
| 104 | + name: "opencv-windows-${{ matrix.config }}" |
| 105 | + path: "release/*.zip" |
| 106 | + |
| 107 | + Release: |
| 108 | + runs-on: "ubuntu-22.04" |
| 109 | + |
| 110 | + if: "github.event_name == 'push' && contains(github.ref, 'refs/tags/')" |
| 111 | + |
| 112 | + needs: |
| 113 | + - "BuildMac" |
| 114 | + - "BuildWindows" |
| 115 | + |
| 116 | + permissions: |
| 117 | + contents: "write" |
| 118 | + |
| 119 | + defaults: |
| 120 | + run: |
| 121 | + shell: "bash" |
| 122 | + |
| 123 | + steps: |
| 124 | + - name: "Get version" |
| 125 | + shell: "bash" |
| 126 | + run: | |
| 127 | + if [[ $GITHUB_REF =~ ^refs/tags/ ]] |
| 128 | + then version="${GITHUB_REF#refs/tags/}" |
| 129 | + else version=main |
| 130 | + fi |
| 131 | + printf "version=%s" "$version" > "$GITHUB_OUTPUT" |
| 132 | + id: "get-version" |
| 133 | + |
| 134 | + - name: "Download build artifacts" |
| 135 | + uses: "actions/download-artifact@v4" |
| 136 | + |
| 137 | + - name: "Create Release" |
| 138 | + uses: "softprops/action-gh-release@d4e8205d7e959a9107da6396278b2f1f07af0f9b" |
| 139 | + with: |
| 140 | + draft: true |
| 141 | + tag_name: "${{ steps.get-version.outputs.version }}" |
| 142 | + name: "${{ steps.get-version.outputs.version }}" |
| 143 | + files: | |
| 144 | + ${{ github.workspace }}/**/*.tar.gz |
| 145 | + ${{ github.workspace }}/**/*.zip |
0 commit comments