From ee83d00866c4422056fb98e1532d6214fec05c1d Mon Sep 17 00:00:00 2001 From: Lakhan Samani Date: Sat, 11 Sep 2021 13:51:00 +0530 Subject: [PATCH] fix: add linux build --- .github/workflows/release.yaml | 38 ++++++++++++++-------------------- Makefile | 2 +- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 840098e..4dd4fcb 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,19 +3,17 @@ on: types: [created] jobs: - releases-windows: + releases: name: Release Authorizer Binary runs-on: ubuntu-latest - strategy: - matrix: - goos: [windows] - goarch: [amd64] steps: - uses: actions/checkout@v2 - name: Install dependencies run: | - sudo apt-get install build-essential wget zip && \ + sudo apt-get install build-essential wget zip gcc-mingw-w64 && \ wget https://golang.org/dl/go1.17.1.linux-amd64.tar.gz && \ + sudo apt-get remove --auto-remove golang-go && \ + sudo rm -rf /usr/bin/go &&\ sudo rm -rf /usr/local/go && \ sudo tar -C /usr/local -xzf go1.17.1.linux-amd64.tar.gz && \ echo PATH=$PATH:/usr/local/go/bin >> ~/.bashrc && \ @@ -30,28 +28,24 @@ jobs: run: whereis go - name: Print Go Version run: go version - - name: Install windows dependencies - if: ${{ matrix.goos == 'windows'}} - run: sudo apt-get install gcc-mingw-w64 - name: Set VERSION env run: echo VERSION=$(basename ${GITHUB_REF}) >> ${GITHUB_ENV} - - name: Echo Version - run: echo ${VERSION} - - name: Set CGO_ENABLED env - run: echo CGO_ENABLED=1 >> ${GITHUB_ENV} && echo GOOS=${{matrix.goos}} >> ${GITHUB_ENV} - - name: CAT ENV - run: cat ${GITHUB_ENV} - - name: Set Windows C Compiler GO env - if: ${{ matrix.goos == 'windows'}} - run: echo CC=/usr/bin/x86_64-w64-mingw32-gcc >> ${GITHUB_ENV} - name: Create build run: make clean && make - - name: Package files - if: ${{ matrix.goos == 'windows'}} + - name: Package files for windows run: | + make clean && CGO_ENABLED=1 GOOS=windows CC=/usr/bin/x86_64-w64-mingw32-gcc make mv .env.sample .env && \ - zip -vr authorizer-${VERSION}-windows-${{matrix.goarch}}.zip .env app build template && \ - github-assets-uploader -f authorizer-${VERSION}-windows-${{matrix.goarch}}.zip -mediatype application/zip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION} + zip -vr authorizer-${VERSION}-windows-amd64.zip .env app build templates + - name: Package files for linux + run: | + make clean && CGO_ENABLED=1 make + mv .env.sample .env && \ + tar cvfz authorizer-${VERSION}-linux-amd64.tar.gz .env app build templates + - name: Upload assets + run: | + github-assets-uploader -f authorizer-${VERSION}-windows-amd64.zip -mediatype application/zip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION} && \ + github-assets-uploader -f authorizer-${VERSION}-linux-amd64.tar.gz -mediatype application/gzip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION} && \ # - uses: wangyoucao577/go-release-action@v1.20 # with: diff --git a/Makefile b/Makefile index c96533b..b23c462 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,6 @@ DEFAULT_VERSION=0.1.0-local VERSION := $(or $(VERSION),$(DEFAULT_VERSION)) cmd: - cd server && CGO_ENABLED=1 GOOS=$(GOOS) CC=$(CC) go build -ldflags "-w -X main.Version=$(VERSION)" -o '../build/server' + cd server && go build -ldflags "-w -X main.Version=$(VERSION)" -o '../build/server' clean: rm -rf build \ No newline at end of file