fork/static-web-server

git clone https://git.julia.blue/fork/static-web-server

Jose Quintanafeat: `armv7-unknown-linux-gnueabihf` target (#586)ee4b049

allow-symlink
8.0 KiB250 linesraw
1name: release
2on:
3  push:
4    tags:
5    - 'v2.[0-9]+.[0-9]+'
6    - 'v2.[0-9]+.[0-9]+-beta.[0-9]+'
7
8jobs:
9  create-release:
10    name: create-release
11    runs-on: ubuntu-22.04
12    outputs:
13      sws_version: ${{ env.SWS_VERSION }}
14    steps:
15      - name: Get the release version from the tag
16        shell: bash
17        if: env.SWS_VERSION == ''
18        run: |
19          # Apparently, this is the right way to get a tag name. Really?
20          #
21          # See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
22          echo "SWS_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
23          echo "version is: ${{ env.SWS_VERSION }}"
24      - name: Checkout repository
25        uses: actions/checkout@v4
26        with:
27          fetch-depth: 1
28      - name: Create GitHub release
29        env:
30          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31        run: |
32          gh release create ${{ env.SWS_VERSION }} --verify-tag --draft --title="${{ env.SWS_VERSION }}"
33
34  build-release:
35    name: build-release
36    needs: ['create-release']
37    runs-on: ${{ matrix.os }}
38    env:
39      # For some builds, we use cross to test on 32-bit and big-endian
40      # systems.
41      CARGO_BIN: cargo
42      # When CARGO_BIN is set to CROSS, this is set to `--target matrix.target`.
43      TARGET_FLAGS: ""
44      # When CARGO_BIN is set to CROSS, TARGET_DIR includes matrix.target.
45      TARGET_DIR: ./target
46      # Emit backtraces on panics.
47      RUST_BACKTRACE: 1
48      # SWS features for Cargo build
49      CARGO_FEATURES: "--features=all"
50    strategy:
51      matrix:
52        build:
53          - linux-musl
54          - linux-musl-arm64
55          - linux-musl-i686
56          - linux-gnu
57          - linux-gnu-arm64
58          - linux-gnu-i686
59          - linux-arm-gnueabihf
60          - linux-musl-armv6
61          - linux-musl-armv7
62          - linux-gnu-armv7
63          - linux-ppc64le
64          - linux-s390x
65          # - linux-android-armv7
66          - linux-android-arm64
67          - netbsd
68          - illumos
69          - macos
70          - macos-arm64
71          - windows-msvc
72          - windows-msvc-i686
73          - windows-msvc-arm64
74          - windows-pc-gnu
75        include:
76        - build: linux-musl
77          os: ubuntu-22.04
78          rust: stable
79          target: x86_64-unknown-linux-musl
80        - build: linux-musl-i686
81          os: ubuntu-22.04
82          rust: stable
83          target: i686-unknown-linux-musl
84        - build: linux-musl-arm64
85          os: ubuntu-22.04
86          rust: stable
87          target: aarch64-unknown-linux-musl
88        - build: linux-gnu
89          os: ubuntu-22.04
90          rust: stable
91          target: x86_64-unknown-linux-gnu
92        - build: linux-gnu-i686
93          os: ubuntu-22.04
94          rust: stable
95          target: i686-unknown-linux-gnu
96        - build: linux-gnu-arm64
97          os: ubuntu-22.04
98          rust: stable
99          target: aarch64-unknown-linux-gnu
100        - build: linux-arm-gnueabihf
101          os: ubuntu-22.04
102          rust: stable
103          target: arm-unknown-linux-gnueabihf
104        - build: linux-musl-armv6
105          os: ubuntu-22.04
106          rust: stable
107          target: arm-unknown-linux-musleabihf
108        - build: linux-musl-armv7
109          os: ubuntu-22.04
110          rust: stable
111          target: armv7-unknown-linux-musleabihf
112        - build: linux-gnu-armv7
113          os: ubuntu-22.04
114          rust: stable
115          target: armv7-unknown-linux-gnueabihf
116        - build: linux-ppc64le
117          os: ubuntu-22.04
118          rust: stable
119          target: powerpc64le-unknown-linux-gnu
120        - build: linux-s390x
121          os: ubuntu-22.04
122          rust: stable
123          target: s390x-unknown-linux-gnu
124        # - build: linux-android-armv7
125        #   os: ubuntu-22.04
126        #   rust: stable
127        #   target: armv7-linux-androideabi
128        - build: linux-android-arm64
129          os: ubuntu-22.04
130          rust: stable
131          target: aarch64-linux-android
132        - build: netbsd
133          os: ubuntu-22.04
134          rust: stable
135          target: x86_64-unknown-netbsd
136        - build: illumos
137          os: ubuntu-22.04
138          rust: stable
139          target: x86_64-unknown-illumos
140        - build: macos
141          os: macos-14
142          rust: stable
143          target: x86_64-apple-darwin
144        - build: macos-arm64
145          os: macos-14
146          rust: stable
147          target: aarch64-apple-darwin
148        - build: windows-msvc
149          os: windows-2022
150          rust: stable
151          target: x86_64-pc-windows-msvc
152        - build: windows-msvc-i686
153          os: windows-2022
154          rust: stable
155          target: i686-pc-windows-msvc
156        - build: windows-msvc-arm64
157          os: windows-2022
158          rust: stable
159          target: aarch64-pc-windows-msvc
160        - build: windows-pc-gnu
161          os: windows-2022
162          rust: stable
163          target: x86_64-pc-windows-gnu
164
165    steps:
166    - name: Checkout repository
167      uses: actions/checkout@v4
168      with:
169        fetch-depth: 1
170
171    - name: Install Linux/BSD tools
172      if: ${{ !contains(matrix.os, 'windows') }}
173      run: scripts/ci/install_tools.sh --target=${{ matrix.target }}
174
175    - name: Install Rust
176      uses: dtolnay/rust-toolchain@stable
177      with:
178        toolchain: ${{ matrix.rust }}
179        target: ${{ matrix.target }}
180
181    - name: Set up Cross
182      shell: bash
183      run: |
184        if [ "${{ matrix.os }}" = "ubuntu-22.04" ]; then
185          # Use 'cargo.sh' script for Android targets only
186          if [[ "${{ matrix.build }}" == "linux-android-armv7" ]] || [[ "${{ matrix.build }}" == "linux-android-arm64" ]]; then
187            echo "CARGO_BIN=scripts/ci/cargo.sh" >> $GITHUB_ENV
188          else
189            target=''
190            case "${{ matrix.os }}" in
191              *macos*)
192                target=x86_64-apple-darwin
193              ;;
194              *)
195                target=x86_64-unknown-linux-musl
196              ;;
197            esac
198
199            echo "Installing cross..."
200            curl -sSL \
201              "https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-$target.tar.gz" \
202              | sudo tar zxf - -C /usr/local/bin/ cross cross-util
203            cross -V
204            echo "CARGO_BIN=/usr/local/bin/cross" >> $GITHUB_ENV
205          fi
206        fi
207        echo "TARGET_FLAGS=--target=${{ matrix.target }}" >> $GITHUB_ENV
208        echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
209
210    - name: Setup Windows ARM64
211      if: ${{ contains(matrix.build, 'windows-msvc-arm64') }}
212      run: |
213        # ring crate: add Visual Studio Build Tools "VS 2022 C++ ARM64 build tools" and "clang" components
214        $env:Path += ";C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\x64\bin"
215
216    - name: Show command used for Cargo
217      run: |
218        echo "cargo command is: ${{ env.CARGO_BIN }}"
219        echo "target flag is: ${{ env.TARGET_FLAGS }}"
220        echo "target dir is: ${{ env.TARGET_DIR }}"
221
222    - name: Build release binary
223      run: ${{ env.CARGO_BIN }} build --bin static-web-server -vv --release ${{ env.CARGO_FEATURES }} ${{ env.TARGET_FLAGS }}
224
225    - name: Build archive
226      shell: bash
227      run: |
228        staging="static-web-server-${{ needs.create-release.outputs.sws_version }}-${{ matrix.target }}"
229        mkdir -p "$staging/"
230        mkdir -p bin
231
232        cp {README.md,LICENSE-APACHE,LICENSE-MIT} "$staging/"
233
234        if [ "${{ matrix.os }}" = "windows-2022" ]; then
235          cp "target/${{ matrix.target }}/release/static-web-server.exe" "$staging/"
236          7z a "$staging.zip" "$staging"
237          echo "ASSET=$staging.zip" >> $GITHUB_ENV
238        else
239          # The man page is only generated on Unix systems.
240          cp "target/${{ matrix.target }}/release/static-web-server" "$staging/"
241          cp "$staging/static-web-server" bin/
242          tar czf "$staging.tar.gz" "$staging"
243          echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
244        fi
245
246    - name: Upload release archive
247      env:
248        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
249      run: |
250        gh release upload ${{ needs.create-release.outputs.sws_version }} ${{ env.ASSET }}