Skip to content

Commit

Permalink
Added github workflow for build and publish.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hintay committed Feb 20, 2022
1 parent f097acb commit 15db0ae
Showing 1 changed file with 135 additions and 0 deletions.
135 changes: 135 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Build and Publish

on:
push:
branches: [ master ]
paths:
- "**/*.js"
- "**/*.vue"
- "frontend/package.json"
- "frontend/.env*"
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"
pull_request:
types: [ opened, synchronize, reopened ]
paths:
- "**/*.js"
- "**/*.vue"
- "frontend/package.json"
- "frontend/.env*"
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"
release:
types:
- published

jobs:
build_frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up nodejs
uses: actions/setup-node@v2
with:
node-version: '14.x'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install dependencies
run: yarn install
working-directory: frontend

- name: Update tranlations
run: make translations
working-directory: frontend

- name: Build
run: |
npx browserslist@latest --update-db
yarn build
working-directory: frontend

- name: Archive frontend artifacts
uses: actions/upload-artifact@v2
with:
name: frontend-dist
path: frontend/dist

- name: Prepare publish
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
run: |
cp README*.md frontend/dist
tar -C ./frontend/dist -zcvf frontend-dist.tar.gz .
- name: Publish
uses: softprops/action-gh-release@v1
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
with:
files: frontend-dist.tar.gz

build_backend:
runs-on: ubuntu-latest
needs: build_frontend
strategy:
matrix:
goos: [linux, darwin]
goarch: [amd64, 386, arm64]
exclude:
# Exclude i386 on darwin.
- goarch: 386
goos: darwin
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
DIST: nginx-ui-${{ matrix.goos }}-${{ matrix.goarch }}
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.17.7

- name: Set up cache
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-${{ env.GOOS }}-${{ env.GOARCH }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ env.GOOS }}-${{ env.GOARCH }}-go-
- name: Download frontend artifacts
uses: actions/download-artifact@v2
with:
name: frontend-dist
path: frontend/dist

- name: Build
run: |
mkdir -p dist
go build -o dist/nginx-ui -v main.go
- name: Archive backend artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ env.DIST }}
path: dist/nginx-ui

- name: Prepare publish
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
run: |
cp README*.md ./dist
tar -C ./dist -zcvf ${{ env.DIST }}.tar.gz .
- name: Publish
uses: softprops/action-gh-release@v1
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
with:
files: ${{ env.DIST }}.tar.gz

0 comments on commit 15db0ae

Please sign in to comment.