|
| 1 | +name: Compute artifact names |
| 2 | +description: Central place for computing the artifact names in the CI builds. |
| 3 | + |
| 4 | +inputs: |
| 5 | + build-name: |
| 6 | + description: > |
| 7 | + The build name (e.g., linux-x86_64, macos-aarch64, etc.). The special |
| 8 | + value "all" can be used to receive a glob that matches all of the build |
| 9 | + names. |
| 10 | + required: true |
| 11 | + |
| 12 | +runs: |
| 13 | + using: composite |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Check valid build name |
| 17 | + if: > |
| 18 | + ! contains( |
| 19 | + fromJson('[ |
| 20 | + "all", |
| 21 | + "linux-x86_64", |
| 22 | + "linux-x86_64-static", |
| 23 | + "macos-x86_64", |
| 24 | + "macos-aarch64", |
| 25 | + "macos-universal" |
| 26 | + ]'), |
| 27 | + inputs.build-name |
| 28 | + ) |
| 29 | + shell: sh |
| 30 | + run: | |
| 31 | + echo '::error::Invalid build name provided: ${{ inputs.build-name }}.' |
| 32 | + exit 1 |
| 33 | +
|
| 34 | + - name: Set artifact names |
| 35 | + id: set-artifact-names |
| 36 | + shell: sh |
| 37 | + env: |
| 38 | + BUILD_NAME: ${{ inputs.build-name == 'all' && '*' || inputs.build-name }} |
| 39 | + run: | |
| 40 | + echo "artifact-name=wasp-cli-${BUILD_NAME}" >> $GITHUB_OUTPUT |
| 41 | + echo "tarball-name=wasp-${BUILD_NAME}.tar.gz" >> $GITHUB_OUTPUT |
| 42 | +
|
| 43 | + - name: Set npm target |
| 44 | + id: set-npm-target |
| 45 | + if: inputs.build-name != 'all' && inputs.build-name != 'macos-universal' |
| 46 | + shell: sh |
| 47 | + run: | |
| 48 | + case '${{ inputs.build-name }}' in |
| 49 | + linux-x86_64) npm_target='{"os":"linux","cpu":"x64","libc":"glibc"}' ;; |
| 50 | + linux-x86_64-static) npm_target='{"os":"linux","cpu":"x64","libc":"musl"}' ;; |
| 51 | + macos-x86_64) npm_target='{"os":"darwin","cpu":"x64"}' ;; |
| 52 | + macos-aarch64) npm_target='{"os":"darwin","cpu":"arm64"}' ;; |
| 53 | + esac |
| 54 | +
|
| 55 | + echo "npm-target=$npm_target" >>"$GITHUB_OUTPUT" |
| 56 | +
|
| 57 | +outputs: |
| 58 | + artifact-name: |
| 59 | + value: ${{ steps.set-artifact-names.outputs.artifact-name }} |
| 60 | + description: "The name of the artifact attached to the CI build." |
| 61 | + tarball-name: |
| 62 | + value: ${{ steps.set-artifact-names.outputs.tarball-name }} |
| 63 | + description: "The name of the tarball inside the artifact." |
| 64 | + npm-target: |
| 65 | + value: ${{ steps.set-npm-target.outputs.npm-target }} |
| 66 | + description: "A JSON-encoded object of {os, cpu, libc?} for this build." |
0 commit comments