From 50492e50618cc2c1d2a5c766901a77af80103f31 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Sun, 20 Aug 2023 22:20:22 +0300 Subject: [PATCH] Add upload artifacts GitHub action --- .github/workflows/release.yml | 168 +++++++++++++++++----------------- 1 file changed, 83 insertions(+), 85 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e272da7c..80e6df3d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: release +name: Release on: workflow_dispatch: @@ -7,93 +7,91 @@ on: # - 'v*' jobs: - build-and-release: + upload-artifact: + name: Upload binaries runs-on: ubuntu-latest + env: { CGO_ENABLED: 0 } steps: - name: Checkout uses: actions/checkout@v3 - - name: Generate changelog - run: | - echo -e "$(git log $(git describe --tags --abbrev=0)..HEAD --oneline | awk '{print "- "$0}')" > CHANGELOG.md - - name: install lipo - run: | - curl -L -o /tmp/lipo https://github.com/konoui/lipo/releases/latest/download/lipo_Linux_amd64 - chmod +x /tmp/lipo - mv /tmp/lipo /usr/local/bin - - name: Build Go binaries - run: | - #!/bin/bash - - export CGO_ENABLED=0 - - mkdir -p artifacts - export GOOS=windows - export GOARCH=amd64 - export FILENAME=artifacts/go2rtc_win64.zip - go build -ldflags "-s -w" -trimpath && 7z a -mx9 -sdel "$FILENAME" go2rtc.exe - - export GOOS=windows - export GOARCH=386 - export FILENAME=artifacts/go2rtc_win32.zip - go build -ldflags "-s -w" -trimpath && 7z a -mx9 -sdel "$FILENAME" go2rtc.exe - - export GOOS=windows - export GOARCH=arm64 - export FILENAME=artifacts/go2rtc_win_arm64.zip - go build -ldflags "-s -w" -trimpath && 7z a -mx9 -sdel "$FILENAME" go2rtc.exe - - export GOOS=linux - export GOARCH=amd64 - export FILENAME=artifacts/go2rtc_linux_amd64 - go build -ldflags "-s -w" -trimpath -o "$FILENAME" - - export GOOS=linux - export GOARCH=386 - export FILENAME=artifacts/go2rtc_linux_i386 - go build -ldflags "-s -w" -trimpath -o "$FILENAME" - - export GOOS=linux - export GOARCH=arm64 - export FILENAME=artifacts/go2rtc_linux_arm64 - go build -ldflags "-s -w" -trimpath -o "$FILENAME" - - export GOOS=linux - export GOARCH=arm - export GOARM=7 - export FILENAME=artifacts/go2rtc_linux_arm - go build -ldflags "-s -w" -trimpath -o "$FILENAME" - - export GOOS=linux - export GOARCH=mipsle - export FILENAME=artifacts/go2rtc_linux_mipsel - go build -ldflags "-s -w" -trimpath -o "$FILENAME" - - export GOOS=darwin - export GOARCH=amd64 - go build -ldflags "-s -w" -trimpath -o go2rtc.amd64 - - export GOOS=darwin - export GOARCH=arm64 - go build -ldflags "-s -w" -trimpath -o go2rtc.arm64 + - name: Setup Go + uses: actions/setup-go@v4 + with: { go-version: '1.20' } - export FILENAME=artifacts/go2rtc_mac_universal.zip - lipo -output go2rtc -create go2rtc.arm64 go2rtc.amd64 && 7z a -mx9 -sdel "$FILENAME" go2rtc - - parallel --jobs $(nproc) "upx {}" ::: artifacts/go2rtc_linux_* - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ failure() }} - - name: Set env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Create GitHub release - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: artifacts/* - generate_release_notes: true - name: Release ${{ env.RELEASE_VERSION }} - body_path: CHANGELOG.md - draft: false - prerelease: false + - name: Build go2rtc_win64 + env: { GOOS: windows, GOARCH: amd64 } + run: go build -ldflags "-s -w" -trimpath + - name: Upload go2rtc_win64 + uses: actions/upload-artifact@v3 + with: { name: go2rtc_win64, path: go2rtc.exe } + + - name: Build go2rtc_win32 + env: { GOOS: windows, GOARCH: 386 } + run: go build -ldflags "-s -w" -trimpath + - name: Upload go2rtc_win32 + uses: actions/upload-artifact@v3 + with: { name: go2rtc_win32, path: go2rtc.exe } + + - name: Build go2rtc_win_arm64 + env: { GOOS: windows, GOARCH: arm64 } + run: go build -ldflags "-s -w" -trimpath + - name: Upload go2rtc_win_arm64 + uses: actions/upload-artifact@v3 + with: { name: go2rtc_win_arm64, path: go2rtc.exe } + + - name: Build go2rtc_linux_amd64 + env: { GOOS: linux, GOARCH: amd64 } + run: go build -ldflags "-s -w" -trimpath + - name: Upload go2rtc_linux_amd64 + uses: actions/upload-artifact@v3 + with: { name: go2rtc_linux_amd64, path: go2rtc } + + - name: Build go2rtc_linux_i386 + env: { GOOS: linux, GOARCH: 386 } + run: go build -ldflags "-s -w" -trimpath + - name: Upload go2rtc_linux_i386 + uses: actions/upload-artifact@v3 + with: { name: go2rtc_linux_i386, path: go2rtc } + + - name: Build go2rtc_linux_arm64 + env: { GOOS: linux, GOARCH: arm64 } + run: go build -ldflags "-s -w" -trimpath + - name: Upload go2rtc_linux_arm64 + uses: actions/upload-artifact@v3 + with: { name: go2rtc_linux_arm64, path: go2rtc } + + - name: Build go2rtc_linux_arm + env: { GOOS: linux, GOARCH: arm, GOARM: 7 } + run: go build -ldflags "-s -w" -trimpath + - name: Upload go2rtc_linux_arm + uses: actions/upload-artifact@v3 + with: { name: go2rtc_linux_arm, path: go2rtc } + + - name: Build go2rtc_linux_armv6 + env: { GOOS: linux, GOARCH: arm, GOARM: 6 } + run: go build -ldflags "-s -w" -trimpath + - name: Upload go2rtc_linux_armv6 + uses: actions/upload-artifact@v3 + with: { name: go2rtc_linux_armv6, path: go2rtc } + + - name: Build go2rtc_linux_mipsel + env: { GOOS: linux, GOARCH: mipsle } + run: go build -ldflags "-s -w" -trimpath + - name: Upload go2rtc_linux_mipsel + uses: actions/upload-artifact@v3 + with: { name: go2rtc_linux_mipsel, path: go2rtc } + + - name: Build go2rtc_mac_amd64 + env: { GOOS: darwin, GOARCH: amd64 } + run: go build -ldflags "-s -w" -trimpath + - name: Upload go2rtc_mac_amd64 + uses: actions/upload-artifact@v3 + with: { name: go2rtc_mac_amd64, path: go2rtc } + + - name: Build go2rtc_mac_arm64 + env: { GOOS: darwin, GOARCH: arm64 } + run: go build -ldflags "-s -w" -trimpath + - name: Upload go2rtc_mac_arm64 + uses: actions/upload-artifact@v3 + with: { name: go2rtc_mac_arm64, path: go2rtc }