From 285df50911376643c8a8f236aee0af6350d13555 Mon Sep 17 00:00:00 2001 From: Eduardo <100472175@alumnos.uc3m.es> Date: Tue, 1 Oct 2024 14:12:23 -0500 Subject: [PATCH] New workflow for releasing --- .github/workflows/go.yml | 60 +++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 1258c19..eb76546 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,4 +1,4 @@ -name: Go-build-macos +name: Go-build-and-release on: push: @@ -8,60 +8,50 @@ on: jobs: build: name: Build - runs-on: ubuntu-latest - strategy: matrix: - os: [macos-latest, ubuntu-latest, windows-latest] + os: [macos, ubuntu, windows] arch: [amd64, arm64] exclude: - - os: windows-latest + - os: windows arch: arm64 go-version: [1.22.x] - steps: - uses: actions/checkout@v4 - - name: Set up Go uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} - - name: Display Go version run: go version - - name: Install dependencies run: go mod tidy - - name: Build - run: go build -v -o agdownloader-${{ matrix.os }}-${{ matrix.arch }} - - - name: Upload binaries + env: + GOOS: ${{ matrix.os }} + GOARCH: ${{ matrix.arch }} + run: | + if [ "${{ matrix.os }}" = "windows" ]; then + go build -v -o agdownloader-${{ matrix.os }}-${{ matrix.arch }}.exe + else + go build -v -o agdownloader-${{ matrix.os }}-${{ matrix.arch }} + fi + - name: Upload artifact uses: actions/upload-artifact@v3 with: name: agdownloader-${{ matrix.os }}-${{ matrix.arch }} - path: agdownloader-${{ matrix.os }}-${{ matrix.arch }} + path: agdownloader-${{ matrix.os }}-${{ matrix.arch }}* create_release: name: Create Release runs-on: ubuntu-latest needs: build - steps: - - name: Download binaries + - name: Download artifacts uses: actions/download-artifact@v3 with: - path: ./binaries - - - name: List files in binaries directory - run: ls -laR ./binaries - - - name: Zip all binaries - run: | - cd binaries - zip -r agdownloader-binaries.zip agdownloader-* - + path: ./artifacts - name: Create Release id: create_release uses: actions/create-release@v1 @@ -72,13 +62,15 @@ jobs: release_name: Release v1.2.${{ github.run_number }} draft: false prerelease: false - - - name: Upload Release Asset - uses: actions/upload-release-asset@v1 + - name: Upload Release Assets env: GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./binaries/agdownloader-binaries.zip - asset_name: agdownloader-binaries.zip - asset_content_type: application/zip + run: | + for file in ./artifacts/*/*; do + asset_name=$(basename "$file") + echo "Uploading $asset_name" + curl -H "Authorization: token $GITHUB_TOKEN" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @"$file" \ + "${{ steps.create_release.outputs.upload_url }}?name=$asset_name" + done \ No newline at end of file