-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added github workflow for build and publish.
- Loading branch information
Showing
1 changed file
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |