mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
commit
c8b1110c7e
1 changed files with 137 additions and 109 deletions
246
.github/workflows/build.yml
vendored
246
.github/workflows/build.yml
vendored
|
@ -32,70 +32,70 @@ jobs:
|
||||||
build_frontend:
|
build_frontend:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set up nodejs
|
- name: Set up nodejs
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: '18.x'
|
node-version: '18.x'
|
||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
cache-dependency-path: 'frontend/yarn.lock'
|
cache-dependency-path: 'frontend/yarn.lock'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install
|
run: yarn install
|
||||||
working-directory: frontend
|
working-directory: frontend
|
||||||
|
|
||||||
- name: Update tranlations
|
- name: Update translations
|
||||||
run: yarn gettext:compile
|
run: yarn gettext:compile
|
||||||
working-directory: frontend
|
working-directory: frontend
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
npx browserslist@latest --update-db
|
npx browserslist@latest --update-db
|
||||||
yarn build
|
yarn build
|
||||||
working-directory: frontend
|
working-directory: frontend
|
||||||
|
|
||||||
- name: Archive frontend artifacts
|
- name: Archive frontend artifacts
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: frontend-dist
|
name: frontend-dist
|
||||||
path: frontend/dist
|
path: frontend/dist
|
||||||
|
|
||||||
- name: Prepare publish
|
- name: Prepare publish
|
||||||
if: github.event_name == 'release'
|
if: github.event_name == 'release'
|
||||||
run: |
|
run: |
|
||||||
cp README*.md frontend/dist
|
cp README*.md frontend/dist
|
||||||
find frontend/dist -printf '%P\n' | tar -C frontend/dist --no-recursion -zcvf frontend-dist.tar.gz -T -
|
find frontend/dist -printf '%P\n' | tar -C frontend/dist --no-recursion -zcvf frontend-dist.tar.gz -T -
|
||||||
|
|
||||||
- name: Publish
|
- name: Publish
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
if: github.event_name == 'release'
|
if: github.event_name == 'release'
|
||||||
with:
|
with:
|
||||||
files: frontend-dist.tar.gz
|
files: frontend-dist.tar.gz
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build_frontend
|
needs: build_frontend
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
goos: [linux, darwin]
|
goos: [ linux, darwin ]
|
||||||
goarch: [amd64, 386, arm64]
|
goarch: [ amd64, 386, arm64 ]
|
||||||
exclude:
|
exclude:
|
||||||
# Exclude i386 on darwin.
|
# Exclude i386 on darwin.
|
||||||
- goarch: 386
|
- goarch: 386
|
||||||
goos: darwin
|
goos: darwin
|
||||||
include:
|
include:
|
||||||
# BEGIN Linux ARM 5 6 7
|
# BEGIN Linux ARM 5 6 7
|
||||||
- goos: linux
|
- goos: linux
|
||||||
goarch: arm
|
goarch: arm
|
||||||
goarm: 7
|
goarm: 7
|
||||||
- goos: linux
|
- goos: linux
|
||||||
goarch: arm
|
goarch: arm
|
||||||
goarm: 6
|
goarm: 6
|
||||||
- goos: linux
|
- goos: linux
|
||||||
goarch: arm
|
goarch: arm
|
||||||
goarm: 5
|
goarm: 5
|
||||||
# END Linux ARM 5 6 7
|
# END Linux ARM 5 6 7
|
||||||
env:
|
env:
|
||||||
CGO_ENABLED: 1
|
CGO_ENABLED: 1
|
||||||
|
@ -103,77 +103,77 @@ jobs:
|
||||||
GOARCH: ${{ matrix.goarch }}
|
GOARCH: ${{ matrix.goarch }}
|
||||||
GOARM: ${{ matrix.goarm }}
|
GOARM: ${{ matrix.goarm }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ^1.19.0
|
go-version: ^1.19.0
|
||||||
|
|
||||||
- name: Set up cache
|
- name: Set up cache
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cache/go-build
|
~/.cache/go-build
|
||||||
~/go/pkg/mod
|
~/go/pkg/mod
|
||||||
key: ${{ runner.os }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}-go-${{ hashFiles('**/go.sum') }}
|
key: ${{ runner.os }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}-go-
|
${{ runner.os }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}-go-
|
||||||
|
|
||||||
- name: Setup compiler environment
|
- name: Setup compiler environment
|
||||||
id: info
|
id: info
|
||||||
run: |
|
run: |
|
||||||
export _NAME=nginx-ui-$(jq ".$GOOS[\"$GOARCH$GOARM\"].name" -r < .github/build/build_info.json)
|
export _NAME=nginx-ui-$(jq ".$GOOS[\"$GOARCH$GOARM\"].name" -r < .github/build/build_info.json)
|
||||||
export _ARCH=$(jq ".$GOOS[\"$GOARCH$GOARM\"].arch" -r < .github/build/build_info.json)
|
export _ARCH=$(jq ".$GOOS[\"$GOARCH$GOARM\"].arch" -r < .github/build/build_info.json)
|
||||||
export _ABI=$(jq ".$GOOS[\"$GOARCH$GOARM\"].abi // \"\"" -r < .github/build/build_info.json)
|
export _ABI=$(jq ".$GOOS[\"$GOARCH$GOARM\"].abi // \"\"" -r < .github/build/build_info.json)
|
||||||
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, ABI: $_ABI, RELEASE_NAME: $_NAME"
|
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, ABI: $_ABI, RELEASE_NAME: $_NAME"
|
||||||
echo "ARCH_NAME=$_ARCH" >> $GITHUB_ENV
|
echo "ARCH_NAME=$_ARCH" >> $GITHUB_ENV
|
||||||
echo "ABI=$_ABI" >> $GITHUB_ENV
|
echo "ABI=$_ABI" >> $GITHUB_ENV
|
||||||
echo "DIST=$_NAME" >> $GITHUB_ENV
|
echo "DIST=$_NAME" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Install musl cross compiler
|
- name: Install musl cross compiler
|
||||||
if: env.GOOS == 'linux'
|
if: env.GOOS == 'linux'
|
||||||
uses: Lesmiscore/musl-cross-compilers@v0.5
|
uses: Lesmiscore/musl-cross-compilers@v0.5
|
||||||
id: musl
|
id: musl
|
||||||
with:
|
with:
|
||||||
target: ${{ env.ARCH_NAME }}-linux-musl${{ env.ABI }}
|
target: ${{ env.ARCH_NAME }}-linux-musl${{ env.ABI }}
|
||||||
|
|
||||||
- name: Post install musl cross compiler
|
- name: Post install musl cross compiler
|
||||||
if: env.GOOS == 'linux'
|
if: env.GOOS == 'linux'
|
||||||
run: |
|
run: |
|
||||||
echo "PATH=${{ steps.musl.outputs.path }}:$PATH" >> $GITHUB_ENV
|
echo "PATH=${{ steps.musl.outputs.path }}:$PATH" >> $GITHUB_ENV
|
||||||
echo "CC=${{ env.ARCH_NAME }}-linux-musl${{ env.ABI }}-gcc" >> $GITHUB_ENV
|
echo "CC=${{ env.ARCH_NAME }}-linux-musl${{ env.ABI }}-gcc" >> $GITHUB_ENV
|
||||||
echo "CXX=${{ env.ARCH_NAME }}-linux-musl${{ env.ABI }}-g++" >> $GITHUB_ENV
|
echo "CXX=${{ env.ARCH_NAME }}-linux-musl${{ env.ABI }}-g++" >> $GITHUB_ENV
|
||||||
echo "LD_FLAGS=--extldflags '-static'" >> $GITHUB_ENV
|
echo "LD_FLAGS=--extldflags '-static'" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Install darwin cross compiler
|
- name: Install darwin cross compiler
|
||||||
if: env.GOOS == 'darwin'
|
if: env.GOOS == 'darwin'
|
||||||
run: |
|
run: |
|
||||||
curl -L https://github.com/Hintay/crossosx/releases/latest/download/crossosx.tar.zst -o crossosx.tar.zst
|
curl -L https://github.com/Hintay/crossosx/releases/latest/download/crossosx.tar.zst -o crossosx.tar.zst
|
||||||
tar xvaf crossosx.tar.zst
|
tar xvaf crossosx.tar.zst
|
||||||
echo "LD_LIBRARY_PATH=$(pwd)/crossosx/lib/" >> $GITHUB_ENV
|
echo "LD_LIBRARY_PATH=$(pwd)/crossosx/lib/" >> $GITHUB_ENV
|
||||||
echo "PATH=$(pwd)/crossosx/bin/:$PATH" >> $GITHUB_ENV
|
echo "PATH=$(pwd)/crossosx/bin/:$PATH" >> $GITHUB_ENV
|
||||||
echo "CC=${{ env.ARCH_NAME }}-clang" >> $GITHUB_ENV
|
echo "CC=${{ env.ARCH_NAME }}-clang" >> $GITHUB_ENV
|
||||||
echo "CXX=${{ env.ARCH_NAME }}-clang++" >> $GITHUB_ENV
|
echo "CXX=${{ env.ARCH_NAME }}-clang++" >> $GITHUB_ENV
|
||||||
echo "LD_FLAGS=-s -w" >> $GITHUB_ENV
|
echo "LD_FLAGS=-s -w" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Download frontend artifacts
|
- name: Download frontend artifacts
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: frontend-dist
|
name: frontend-dist
|
||||||
path: frontend/dist
|
path: frontend/dist
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
go build -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/server/settings.buildTime=$(date +%s)'" -o dist/nginx-ui -v main.go
|
go build -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/server/settings.buildTime=$(date +%s)'" -o dist/nginx-ui -v main.go
|
||||||
|
|
||||||
- name: Archive backend artifacts
|
- name: Archive backend artifacts
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: ${{ env.DIST }}
|
name: ${{ env.DIST }}
|
||||||
path: dist/nginx-ui
|
path: dist/nginx-ui
|
||||||
|
|
||||||
- name: Prepare publish
|
- name: Prepare publish
|
||||||
if: github.event_name == 'release'
|
if: github.event_name == 'release'
|
||||||
|
@ -186,3 +186,31 @@ jobs:
|
||||||
if: github.event_name == 'release'
|
if: github.event_name == 'release'
|
||||||
with:
|
with:
|
||||||
files: ${{ env.DIST }}.tar.gz
|
files: ${{ env.DIST }}.tar.gz
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
if: github.event_name == 'release' && env.GOOS == 'linux' && env.GOARCH == 'amd64'
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
if: github.event_name == 'release' && env.GOOS == 'linux' && env.GOARCH == 'amd64'
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USER }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Prepare Dockerfile
|
||||||
|
if: github.event_name == 'release' && env.GOOS == 'linux' && env.GOARCH == 'amd64'
|
||||||
|
run: |
|
||||||
|
cp ./Dockerfile ./dist
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
if: github.event_name == 'release' && env.GOOS == 'linux' && env.GOARCH == 'amd64'
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: ./dist
|
||||||
|
file: ./dist/Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: |
|
||||||
|
uozi/nginx-ui:latest
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue