From e050313deb4940dac432a6ce5fe5c313b416282e Mon Sep 17 00:00:00 2001 From: Mogyuchi Date: Sun, 25 Aug 2024 02:48:27 +0900 Subject: [PATCH] ci: get BINARY_NAME from `cargo metadata` --- .github/workflows/build.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7502dff..9f1df97 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,13 +19,23 @@ env: # const IMAGE_REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} - BINARY_NAME: ${{ github.event.repository.name }} # env RUSTFLAGS: "-Dwarnings" jobs: - build: + env: if: ${{ !( github.workflow == 'build' && startsWith(github.event.head_commit.message, 'release:') && github.event.head_commit.author.name == 'mazi-release[bot]' ) }} + runs-on: ubuntu-latest + outputs: + BINARY_NAME: ${{ steps.meta.outputs.BINARY_NAME }} + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - id: meta + run: | + echo "BINARY_NAME=$(cargo metadata --offline --no-deps --format-version=1 | jq -r '.packages[].targets[] | select(.kind | map(. == "bin") | any ) | .name')" >> $GITHUB_OUTPUT + + build: + needs: [env] permissions: contents: write strategy: @@ -80,11 +90,11 @@ jobs: working-directory: dist/ run: | if [ -e binary.exe ]; then - filename="${{ env.BINARY_NAME }}-${{ inputs.tag-name }}-${{ matrix.target }}.exe" + filename="${{ needs.env.outputs.BINARY_NAME }}-${{ inputs.tag-name }}-${{ matrix.target }}.exe" mv binary.exe "$filename" gh release upload ${{ inputs.tag-name }} "$filename"#${{ matrix.target }} --clobber else - filename="${{ env.BINARY_NAME }}-${{ inputs.tag-name }}-${{ matrix.target }}" + filename="${{ needs.env.outputs.BINARY_NAME }}-${{ inputs.tag-name }}-${{ matrix.target }}" mv binary "$filename" gh release upload ${{ inputs.tag-name }} "$filename"#${{ matrix.target }} --clobber fi