Skip to content

Commit

Permalink
using docker
Browse files Browse the repository at this point in the history
  • Loading branch information
twobitEDD committed Mar 7, 2024
1 parent 16d64ff commit 0836c01
Showing 1 changed file with 21 additions and 59 deletions.
80 changes: 21 additions & 59 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,29 @@ name: Build and Release
on:
push:
tags:
- '*'

- 'v*'
jobs:
build:
strategy:
matrix:
goos: [windows, linux, darwin]
goarch: [amd64, arm64]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.20'
- name: Build
run: |
export GOOS=${{ matrix.goos }}
export GOARCH=${{ matrix.goarch }}
for dir in $(go list -f '{{.Dir}}' ./...); do
pkg=$(basename $dir)
go build -v -o ${pkg}-${{ matrix.goos }}-${{ matrix.goarch }} $dir
done
- name: Archive production artifacts
uses: actions/upload-artifact@v2
with:
name: servnode-${{ matrix.goos }}-${{ matrix.goarch }}
path: ./servnode-${{ matrix.goos }}-${{ matrix.goarch }}

release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download Artifacts
uses: actions/download-artifact@v2
- name: Install zip
run: sudo apt-get install zip
- name: Zip Artifacts
run: |
for file in $(ls); do
if [[ -f $file ]]; then
zip ${file%.*}.zip $file
fi
done
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.SERV_BUILD_KEY }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
- name: Check out code
uses: actions/checkout@v2

- name: Set up Docker
uses: docker/setup-buildx-action@v1

- name: Run GoReleaser
env:
GITHUB_TOKEN: ${{ secrets.SERV_BUILD_KEY }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./*.zip
asset_name: servnode-${{ matrix.goos }}-${{ matrix.goarch }}.zip
asset_content_type: application/zip
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker run \
--rm \
--privileged \
-e CGO_ENABLED=1 \
-e GITHUB_TOKEN \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${{ github.workspace }}:/go/src/github.com/servprotocolorg/serv \
-w /go/src/github.com/servprotocolorg/serv \
ghcr.io/goreleaser/goreleaser-cross:v1.20 \
release --rm-dist

0 comments on commit 0836c01

Please sign in to comment.