87 lines
3.2 KiB
YAML
87 lines
3.2 KiB
YAML
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
logLevel:
|
|
description: 'Log level'
|
|
required: true
|
|
default: 'warning'
|
|
type: choice
|
|
options:
|
|
- info
|
|
- warning
|
|
- debug
|
|
tags:
|
|
description: 'Tags'
|
|
required: false
|
|
type: boolean
|
|
release:
|
|
types: [created]
|
|
|
|
jobs:
|
|
releases:
|
|
name: Release Authorizer Binary
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '16'
|
|
- uses: actions/setup-go@v2
|
|
with:
|
|
go-version: '^1.17.3'
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get install build-essential wget zip gcc-mingw-w64 && \
|
|
echo "/usr/bin/x86_64-w64-mingw32-gcc" >> GITHUB_PATH && \
|
|
wget --no-check-certificate --progress=dot:mega https://github.com/wangyoucao577/assets-uploader/releases/download/v0.3.0/github-assets-uploader-v0.3.0-linux-amd64.tar.gz -O github-assets-uploader.tar.gz && \
|
|
tar -zxf github-assets-uploader.tar.gz && \
|
|
sudo mv github-assets-uploader /usr/sbin/ && \
|
|
sudo rm -f github-assets-uploader.tar.gz && \
|
|
github-assets-uploader -version && \
|
|
make build-app && \
|
|
make build-dashboard
|
|
- name: Print Go paths
|
|
run: whereis go
|
|
- name: Print Go Version
|
|
run: go version
|
|
- name: Set VERSION env
|
|
run: echo VERSION=$(basename ${GITHUB_REF}) >> ${GITHUB_ENV}
|
|
- name: Copy .env file
|
|
run: mv .env.sample .env
|
|
- name: Package files for windows
|
|
run: |
|
|
make clean && \
|
|
CGO_ENABLED=1 GOOS=windows CC=/usr/bin/x86_64-w64-mingw32-gcc make && \
|
|
mv build/server build/server.exe && \
|
|
zip -vr authorizer-${VERSION}-windows-amd64.zip .env app/build build templates dashboard/build
|
|
- name: Package files for linux
|
|
run: |
|
|
make clean && \
|
|
CGO_ENABLED=1 make && \
|
|
tar cvfz authorizer-${VERSION}-linux-amd64.tar.gz .env app/build build templates dashboard/build
|
|
- 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}
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v3
|
|
with:
|
|
images: lakhansamani/authorizer
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
|