diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5ab6d802d..bb69842bc 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -5,14 +5,22 @@ on: secrets: SECRET: required: true + workflow_dispatch: + +env: + SECRET: ${{ secrets.SECRET }} jobs: - build-linux: - name: "Build for linux" + build-backend-linux: + name: "Build backend for linux" runs-on: ubuntu-latest + # Runs on alpine because it is easier to staticly link the library container: - image: golang:alpine + image: golang:alpine + + env: + BACKEND_DIR: ./backend steps: - name: "Install packages" @@ -21,17 +29,16 @@ jobs: - uses: actions/checkout@v3 - name: "Create output path" + working-directory: "${{env.BACKEND_DIR}}" run: mkdir ./output - name: "Load secret" - env: - SECRET: ${{ secrets.SECRET }} + working-directory: "${{env.BACKEND_DIR}}" run: | - echo "$SECRET" > ./src/excel/secret.json - echo "$SECRET" > ./src/excel_adapter/internals/secret.json + ./load-secret.sh "$SECRET" - - name: "Build for amd46 (64 bit)" - working-directory: ./src + - name: "Build (64 bit)" + working-directory: "${{env.BACKEND_DIR}}/cmd" env: CGO_ENABLED: 1 GOARCH: amd64 @@ -43,42 +50,99 @@ jobs: uses: actions/upload-artifact@v2 with: name: backend-linux - path: ./output/backend-linux-64 + path: "${{env.BACKEND_DIR}}/output/*" - build-windows: - name: "Build for windows" + build-backend-windows: + name: "Build backend for windows" runs-on: windows-latest + env: + BACKEND_DIR: ".\\backend" + steps: - uses: actions/checkout@v3 - name: "Setup Go" uses: actions/setup-go@v4 with: - go-version: "1.20" - cache-dependency-path: ".\\src\\go.sum" + go-version: "1.19" + cache-dependency-path: "${{env.BACKEND_DIR}}\\go.sum" - name: "Load secret" - env: - SECRET: ${{ secrets.SECRET }} + working-directory: "${{env.BACKEND_DIR}}" run: | - echo "$env:SECRET" > .\src\excel\secret.json - echo "$env:SECRET" > .\src\excel_adapter\internals\secret.json + echo "${{env.SECRET}}" > ".\internal\excel\secret.json" && + echo "${{env.SECRET}}" > ".\internal\excel_adapter\internals\secret.json" && + echo "${{env.SECRET}}" > ".\pkg\excel\secret.json" && + echo "${{env.SECRET}}" > ".\pkg\excel_adapter\internals\secret.json" - name: "Create output path" + working-directory: "${{env.BACKEND_DIR}}" run: mkdir .\output - - name: "Build for amd46 (64 bit)" - working-directory: .\src + - name: "Build (64 bit)" + working-directory: "${{env.BACKEND_DIR}}\\cmd" env: CGO_ENABLED: 1 GOARCH: amd64 GOOS: windows run: | - go build -ldflags '-linkmode external -extldflags "-static"' -o ..\output\backend-windows-64.exe + go build -o ..\output\backend-windows-64.exe - name: "Uplaod artifacts" - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: backend-windows - path: ./output/backend-windows-64.exe + path: "${{env.BACKEND_DIR}}\\output\\*" + + build-backend-mac: + name: "Build backend for macOS" + runs-on: macos-latest + + env: + BACKEND_DIR: ./backend + + steps: + - name: "Install packages" + run: brew install libpcap + + - name: "Setup Go" + uses: actions/setup-go@v4 + with: + go-version: "1.19" + cache-dependency-path: "${{env.BACKEND_DIR}}/go.sum" + + - uses: actions/checkout@v3 + + - name: "Create output path" + working-directory: "${{env.BACKEND_DIR}}" + run: mkdir ./output + + - name: "Load secret" + working-directory: "${{env.BACKEND_DIR}}" + run: | + ./load-secret.sh "$SECRET" + + - name: "Build (64 bit)" + working-directory: "${{env.BACKEND_DIR}}/cmd" + env: + CGO_ENABLED: 1 + GOARCH: amd64 + GOOS: darwin + run: | + go build -o ../output/backend-macos-64 + + - name: "Build (apple 64 bit)" + working-directory: "${{env.BACKEND_DIR}}/cmd" + env: + CGO_ENABLED: 1 + GOARCH: arm64 + GOOS: darwin + run: | + go build -o ../output/backend-macos-m1-64 + + - name: "Uplaod artifacts" + uses: actions/upload-artifact@v3 + with: + name: backend-macos + path: "${{env.BACKEND_DIR}}/output/*" diff --git a/backend/load-secret.sh b/backend/load-secret.sh new file mode 100755 index 000000000..105c658e3 --- /dev/null +++ b/backend/load-secret.sh @@ -0,0 +1,9 @@ +if [ $# -ne 1 ]; then + echo "expected at least one argument"; + exit 1; +fi + +echo "$1" > "./internal/excel/secret.json" +echo "$1" > "./internal/excel_adapter/internals/secret.json" +echo "$1" > "./pkg/excel/secret.json" +echo "$1" > "./pkg/excel_adapter/internals/secret.json" diff --git a/load-secret.sh b/load-secret.sh deleted file mode 100755 index 83a55592f..000000000 --- a/load-secret.sh +++ /dev/null @@ -1,9 +0,0 @@ -if [ $# -ne 1 ]; then - echo "expected at least one argument"; - exit 1; -fi - -echo "$1" > "./backend/internal/excel/secret.json" -echo "$1" > "./backend/internal/excel_adapter/internals/secret.json" -echo "$1" > "./backend/pkg/excel/secret.json" -echo "$1" > "./backend/pkg/excel_adapter/internals/secret.json" \ No newline at end of file