ci: work on artifact names for upload

This commit is contained in:
Eugen Eisler 2024-09-12 19:35:23 +02:00
parent 6fdf17b466
commit 069cf0ff3d

View File

@ -51,13 +51,10 @@ jobs:
run: |
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
echo "OS=linux" >> $GITHUB_ENV
echo "EXT=" >> $GITHUB_ENV
elif [ "${{ matrix.os }}" == "macos-latest" ]; then
echo "OS=darwin" >> $GITHUB_ENV
echo "EXT=" >> $GITHUB_ENV
else
echo "OS=windows" >> $GITHUB_ENV
echo "EXT=.exe" >> $GITHUB_ENV
fi
shell: bash
@ -67,7 +64,7 @@ jobs:
GOOS: ${{ env.OS }}
GOARCH: ${{ matrix.arch }}
run: |
go build -o fabric-${OS}-${{ matrix.arch }}-${{ github.ref_name }} .
go build -o fabric-${OS}-${{ matrix.arch }} .
- name: Build binary on Windows
if: matrix.os == 'windows-latest'
@ -75,13 +72,21 @@ jobs:
GOOS: windows
GOARCH: ${{ matrix.arch }}
run: |
go build -o fabric-${OS}-${{ matrix.arch }}-${{ github.ref_name }}${EXT} .
go build -o fabric-windows-${{ matrix.arch }}.exe .
- name: Upload build artifact
if: matrix.os != 'windows-latest'
uses: actions/upload-artifact@v3
with:
name: fabric-${OS}-${{ matrix.arch }}-${{ github.ref_name }}
path: fabric-${OS}-${{ matrix.arch }}-${{ github.ref_name }}${EXT}
name: fabric-${OS}-${{ matrix.arch }}
path: fabric-${OS}-${{ matrix.arch }}
- name: Upload build artifact
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v3
with:
name: fabric-windows-${{ matrix.arch }}.exe
path: fabric-windows-${{ matrix.arch }}.exe
- name: Create release if it doesn't exist
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
@ -91,8 +96,15 @@ jobs:
gh release view ${{ github.ref_name }} || gh release create ${{ github.ref_name }} --title "Release ${{ github.ref_name }}" --notes "Automated release for ${{ github.ref_name }}"
- name: Upload release artifact
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && matrix.os == 'windows-latest'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} fabric-${OS}-${{ matrix.arch }}-${{ github.ref_name }}${EXT}
gh release upload ${{ github.ref_name }} fabric-windows-${{ matrix.arch }}.exe
- name: Upload release artifact
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && matrix.os != 'windows-latest'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} fabric-${OS}-${{ matrix.arch }}