Skip to content

Merge pull request #27 from hero-soft/test #55

Merge pull request #27 from hero-soft/test

Merge pull request #27 from hero-soft/test #55

name: Build and Create Release
on:
push:
# branches:
# - "main"
# pull_request:
# branches:
# - "*"
# - "!main"
jobs:
# setup-matrix:
# runs-on: ubuntu-latest
# outputs:
# matrix: ${{ steps.set-matrix.outputs.matrix }}
# steps:
# - id: set-matrix
# run: |
# TASKS=$(echo $(cat .github/workflows/go-matrix.json) | sed 's/ //g' )
# echo 'matrix=$TASKS' >> $GITHUB_OUTPUT
build-server:
name: Build Server
runs-on: ubuntu-latest
strategy:
matrix:
target:
- os: darwin
arch: amd64
- os: darwin
arch: arm64
- os: linux
arch: 386
- os: linux
arch: amd64
- os: linux
arch: arm
- os: linux
arch: arm64
- os: windows
arch: 386
ext: .exe
- os: windows
arch: amd64
ext: .exe
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: 'server/go.mod'
cache: true
cache-dependency-path: server/go.sum
- name: Build server
run: cd ./server; GOOS="${{ matrix.target.os }}" GOARCH="${{ matrix.target.arch }}" go build -o ../dist/server/web-scanner-${{ matrix.target.os }}-${{ matrix.target.arch }}${{ matrix.target.ext }} .
- name: Copy server default settings file
run: cp ./server/settings.toml ./dist/server
- name: Copy README to dist
run: cp ./README.md ./dist/server
- name: Set permissions
run: chmod 775 ./dist/server/web-scanner-${{ matrix.target.os }}-${{ matrix.target.arch }}${{ matrix.target.ext }}
- name: Archive Server
uses: actions/upload-artifact@v3
with:
name: web-scanner-${{ matrix.target.os }}-${{ matrix.target.arch }}
retention-days: 5
path: |
./dist/server
build-client:
name: Build client
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
cache-dependency-path: "./client/package-lock.json"
- name: Install dependencies (with force)
run: cd ./client; npm install --force
- name: Build client
run: cd ./client; npm run build-actions
- name: Archive Client
uses: actions/upload-artifact@v3
with:
name: client
retention-days: 5
path: |
./dist/client
zip-file:
name: Zip files
runs-on: ubuntu-latest
needs: [build-server, build-client]
strategy:
matrix:
target:
- os: darwin
arch: amd64
- os: darwin
arch: arm64
- os: linux
arch: 386
- os: linux
arch: amd64
- os: linux
arch: arm
- os: linux
arch: arm64
- os: windows
ext: .exe
arch: 386
- os: windows
arch: amd64
ext: .exe
steps:
- name: Download Client
uses: actions/download-artifact@v3
with:
name: client
path: ./web-scanner/client
- name: Download Server
uses: actions/download-artifact@v3
with:
name: web-scanner-${{ matrix.target.os }}-${{ matrix.target.arch }}
path: ./web-scanner
- run: |
zip -r ./web-scanner-${{ matrix.target.os }}-${{ matrix.target.arch }}.zip ./web-scanner
- name: Archive Client
uses: actions/upload-artifact@v3
with:
name: zips
retention-days: 5
path: |
web-scanner-${{ matrix.target.os }}-${{ matrix.target.arch }}.zip
release:
name: release
runs-on: ubuntu-latest
needs: zip-file
steps:
- name: Download Zips
uses: actions/download-artifact@v3
with:
name: zips
path: ./dist
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
files: |
./dist
# - name: Create Release
# run: gh release create ${{ github.ref }} --generate-notes
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}