Skip to content

Commit

Permalink
ci: get BINARY_NAME from cargo metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogyuchi committed Aug 24, 2024
1 parent c5dd91c commit e050313
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e050313

Please sign in to comment.