From 51d401b8173aaac6839fb3325f604bff1927998e Mon Sep 17 00:00:00 2001 From: doorbash Date: Tue, 30 Nov 2021 21:13:56 +0330 Subject: [PATCH] add release.yml --- .github/workflows/goreleaser.yml | 28 ---------------------- .github/workflows/release.yml | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 28 deletions(-) delete mode 100644 .github/workflows/goreleaser.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml deleted file mode 100644 index d33bd86..0000000 --- a/.github/workflows/goreleaser.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: goreleaser - -on: - release: - types: [published] - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 - with: - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6672f29 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: release + +on: + release: + types: [published] + +jobs: + generate: + name: Generate cross-platform builds + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + + - name: Setup go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + + - name: Print go tool dist list + run: go tool dist list + + - name: Build + run: | + platforms=("linux/amd64" "darwin/amd64" "windows/amd64") + for x in "${platforms[@]}"; do + os=${x%%/*} + arch=${x##*/} + filename=${{ github.event.repository.name }}-$os-$arch + if [ "$os" == "windows" ]; then + filename+=".exe" + fi + GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -o dist/$filename -trimpath -ldflags "-s -w" + done + - name: Upload build-artifacts + uses: skx/github-action-publish-binaries@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: "./dist/*"