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