|
@@ -0,0 +1,137 @@
|
|
|
|
+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:
|
|
|
|
+ - name: Checkout
|
|
|
|
+ uses: actions/checkout@v2
|
|
|
|
+
|
|
|
|
+ - name: Set up nodejs
|
|
|
|
+ uses: actions/setup-node@v2
|
|
|
|
+ with:
|
|
|
|
+ node-version: '14.x'
|
|
|
|
+ cache: 'yarn'
|
|
|
|
+ cache-dependency-path: frontend/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'
|
|
|
|
+ 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'
|
|
|
|
+ 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:
|
|
|
|
+ - name: Checkout
|
|
|
|
+ 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'
|
|
|
|
+ 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'
|
|
|
|
+ with:
|
|
|
|
+ files: ${{ env.DIST }}.tar.gz
|