Skip to content

Commit

Permalink
New workflow for releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
Astrak00 committed Oct 1, 2024
1 parent e662dfe commit 285df50
Showing 1 changed file with 26 additions and 34 deletions.
60 changes: 26 additions & 34 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Go-build-macos
name: Go-build-and-release

on:
push:
Expand All @@ -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
Expand All @@ -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

0 comments on commit 285df50

Please sign in to comment.