mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
Added github workflow for build and publish.
This commit is contained in:
parent
f097acb3e9
commit
15db0ae484
1 changed files with 135 additions and 0 deletions
135
.github/workflows/build.yml
vendored
Normal file
135
.github/workflows/build.yml
vendored
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue