|
1 | 1 | name: Build and Publish |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: [main] |
6 | | - pull_request: |
7 | | - branches: [main] |
8 | | - release: |
9 | | - types: |
10 | | - - published |
11 | | - workflow_dispatch: |
| 4 | + workflow_call: |
12 | 5 | inputs: |
13 | 6 | tag_name: |
14 | 7 | description: "Tag name" |
|
20 | 13 | type: boolean |
21 | 14 |
|
22 | 15 | jobs: |
23 | | - check: |
24 | | - name: Check |
25 | | - runs-on: ubuntu-latest |
26 | | - steps: |
27 | | - - uses: actions/checkout@v4 |
28 | | - - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b |
29 | | - with: |
30 | | - toolchain: stable |
31 | | - - run: cargo check |
32 | | - |
33 | | - test: |
34 | | - name: Test |
35 | | - runs-on: ubuntu-latest |
36 | | - steps: |
37 | | - - uses: actions/checkout@v4 |
38 | | - - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b |
39 | | - with: |
40 | | - toolchain: stable |
41 | | - - run: cargo test |
42 | | - |
43 | | - fmt: |
44 | | - name: Format |
45 | | - runs-on: ubuntu-latest |
46 | | - steps: |
47 | | - - uses: actions/checkout@v4 |
48 | | - - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b |
49 | | - with: |
50 | | - toolchain: stable |
51 | | - components: rustfmt |
52 | | - - run: cargo fmt --all -- --check |
53 | | - |
54 | | - clippy: |
55 | | - name: Clippy |
56 | | - runs-on: ubuntu-latest |
57 | | - steps: |
58 | | - - uses: actions/checkout@v4 |
59 | | - - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b |
60 | | - with: |
61 | | - toolchain: stable |
62 | | - components: clippy |
63 | | - - run: cargo clippy -- -D warnings |
64 | | - |
65 | 16 | build-and-publish: |
66 | 17 | name: Build and Publish |
67 | 18 | runs-on: ${{ matrix.os }} |
68 | 19 | strategy: |
69 | 20 | matrix: |
70 | 21 | include: |
71 | | - - name: linux |
| 22 | + - name: x86_64-unknown-linux-gnu |
72 | 23 | os: ubuntu-22.04 # Use oldest supported non-deprecated version so we link against older glibc version which allows running binary on a wider set of Linux systems |
73 | 24 | path: target/x86_64-unknown-linux-gnu/release/function-runner |
74 | 25 | asset_name: function-runner-x86_64-linux-${{ inputs.tag_name || github.event.release.tag_name }} |
75 | 26 | shasum_cmd: sha256sum |
76 | | - target: x86_64-unknown-linux-gnu |
77 | | - - name: linux-arm64 |
| 27 | + - name: aarch64-unknown-linux-gnu |
78 | 28 | os: ubuntu-22.04 # Use oldest supported non-deprecated version so we link against older glibc version which allows running binary on a wider set of Linux systems |
79 | 29 | path: target/aarch64-unknown-linux-gnu/release/function-runner |
80 | 30 | asset_name: function-runner-arm-linux-${{ inputs.tag_name || github.event.release.tag_name }} |
81 | 31 | shasum_cmd: sha256sum |
82 | | - target: aarch64-unknown-linux-gnu |
83 | | - - name: macos |
| 32 | + - name: x86_64-apple-darwin |
84 | 33 | os: macos-latest |
85 | 34 | path: target/x86_64-apple-darwin/release/function-runner |
86 | 35 | asset_name: function-runner-x86_64-macos-${{ inputs.tag_name || github.event.release.tag_name }} |
87 | 36 | shasum_cmd: shasum -a 256 |
88 | | - target: x86_64-apple-darwin |
89 | | - - name: arm64-macos |
| 37 | + - name: aarch64-apple-darwin |
90 | 38 | os: macos-latest |
91 | 39 | path: target/aarch64-apple-darwin/release/function-runner |
92 | 40 | asset_name: function-runner-arm-macos-${{ inputs.tag_name || github.event.release.tag_name }} |
93 | 41 | shasum_cmd: shasum -a 256 |
94 | | - target: aarch64-apple-darwin |
95 | | - - name: windows |
| 42 | + - name: x86_64-pc-windows-msvc |
96 | 43 | os: windows-latest |
97 | 44 | path: target\x86_64-pc-windows-msvc\release\function-runner.exe |
98 | 45 | asset_name: function-runner-x86_64-windows-${{ inputs.tag_name || github.event.release.tag_name }} |
99 | 46 | shasum_cmd: sha256sum |
100 | | - target: x86_64-pc-windows-msvc |
101 | 47 |
|
102 | 48 | steps: |
103 | 49 | - uses: actions/checkout@v4 |
104 | 50 |
|
105 | 51 | - name: Install cross compiler |
106 | | - if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }} |
| 52 | + if: ${{ matrix.name == 'aarch64-unknown-linux-gnu' }} |
107 | 53 | run: | |
108 | 54 | sudo apt-get update |
109 | 55 | sudo apt-get install -y gcc-aarch64-linux-gnu |
110 | 56 |
|
111 | 57 | - name: Set up cross compiler env variables |
112 | | - if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }} |
| 58 | + if: ${{ matrix.name == 'aarch64-unknown-linux-gnu' }} |
113 | 59 | run: | |
114 | 60 | echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV |
115 | 61 | echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV |
116 | 62 | echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV |
117 | 63 |
|
118 | 64 | # Should no-op except for macos-arm case where that target won't be installed |
119 | 65 | - name: Install target |
120 | | - run: rustup target add ${{ matrix.target }} |
| 66 | + run: rustup target add ${{ matrix.name }} |
121 | 67 |
|
122 | | - - name: Build ${{ matrix.target }} |
123 | | - run: cargo build --release --target ${{ matrix.target }} --package function-runner |
| 68 | + - name: Build ${{ matrix.name }} |
| 69 | + run: cargo build --release --target ${{ matrix.name }} --package function-runner |
124 | 70 |
|
125 | 71 | - name: Archive assets |
126 | 72 | if: ${{ inputs.should_publish }} |
127 | 73 | run: gzip -k -f ${{ matrix.path }} && mv ${{ matrix.path }}.gz ${{ matrix.asset_name }}.gz |
128 | 74 |
|
129 | | - - name: Upload assets to artifacts |
130 | | - if: ${{ inputs.should_publish }} |
131 | | - uses: actions/upload-artifact@v4 |
132 | | - with: |
133 | | - name: ${{ matrix.asset_name }}.gz |
134 | | - path: ${{ matrix.asset_name }}.gz |
135 | | - |
136 | | - - name: Upload assets to release |
137 | | - if: ${{ inputs.should_publish }} |
138 | | - env: |
139 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
140 | | - run: gh release upload ${{ inputs.tag_name || github.event.release.tag_name }} ${{ matrix.asset_name }}.gz |
141 | | - |
142 | | - - name: Generate asset hash |
143 | | - if: ${{ inputs.should_publish }} |
144 | | - run: ${{ matrix.shasum_cmd }} ${{ matrix.asset_name }}.gz | awk '{ print $1 }' > ${{ matrix.asset_name }}.gz.sha256 |
145 | | - |
146 | | - - name: Upload asset hash to artifacts |
147 | | - if: ${{ inputs.should_publish }} |
148 | | - uses: actions/upload-artifact@v4 |
149 | | - with: |
150 | | - name: ${{ matrix.asset_name }}.gz.sha256 |
151 | | - path: ${{ matrix.asset_name }}.gz.sha256 |
152 | | - |
153 | | - - name: Upload asset hash to release |
154 | | - if: ${{ inputs.should_publish }} |
155 | | - env: |
156 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
157 | | - run: gh release upload ${{ inputs.tag_name || github.event.release.tag_name }} ${{ matrix.asset_name }}.gz.sha256 |
| 75 | + # - name: Upload assets to artifacts |
| 76 | + # if: ${{ inputs.should_publish }} |
| 77 | + # uses: actions/upload-artifact@v4 |
| 78 | + # with: |
| 79 | + # name: ${{ matrix.asset_name }}.gz |
| 80 | + # path: ${{ matrix.asset_name }}.gz |
| 81 | + |
| 82 | + # - name: Upload assets to release |
| 83 | + # if: ${{ inputs.should_publish }} |
| 84 | + # env: |
| 85 | + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + # run: gh release upload ${{ inputs.tag_name || github.event.release.tag_name }} ${{ matrix.asset_name }}.gz |
| 87 | + |
| 88 | + # - name: Generate asset hash |
| 89 | + # if: ${{ inputs.should_publish }} |
| 90 | + # run: ${{ matrix.shasum_cmd }} ${{ matrix.asset_name }}.gz | awk '{ print $1 }' > ${{ matrix.asset_name }}.gz.sha256 |
| 91 | + |
| 92 | + # - name: Upload asset hash to artifacts |
| 93 | + # if: ${{ inputs.should_publish }} |
| 94 | + # uses: actions/upload-artifact@v4 |
| 95 | + # with: |
| 96 | + # name: ${{ matrix.asset_name }}.gz.sha256 |
| 97 | + # path: ${{ matrix.asset_name }}.gz.sha256 |
| 98 | + |
| 99 | + # - name: Upload asset hash to release |
| 100 | + # if: ${{ inputs.should_publish }} |
| 101 | + # env: |
| 102 | + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + # run: gh release upload ${{ inputs.tag_name || github.event.release.tag_name }} ${{ matrix.asset_name }}.gz.sha256 |
0 commit comments