Skip to content

fix(ci): new way to use env vars (#156) #65

fix(ci): new way to use env vars (#156)

fix(ci): new way to use env vars (#156) #65

Workflow file for this run

name: Build & Deploy
on: [push]
env:
SCRVER: ${{ github.sha }}
jobs:
server:
name: Build Server
runs-on: ubuntu-latest
env:
GO111MODULE: "on"
CGO_ENABLED: 0
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Set version env
run: |
echo "SCRVER=$(git describe --always --long --dirty)" >> "$GITHUB_ENV"
- name: Install Golang
uses: actions/setup-go@v4
with:
go-version: "1.13.15"
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: "18.4.0"
- name: Export bin paths
run: |
echo "GOPATH=$(go env GOPATH)" >> "$GITHUB_ENV"
echo "GOBIN=$(go env GOPATH)/bin" >> "$GITHUB_ENV"
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Create bin paths
run: |
mkdir -p $GOBIN
- name: Install PostCSS CLI
run: npm i -g postcss-cli
- name: Install Golang Dep
run: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- name: Install Packr2
run: go get github.com/gobuffalo/packr/v2/packr2@v2.6.0
- name: Install UPX
run: |
wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz
tar -xf upx-3.95-amd64_linux.tar.xz
mv upx-3.95-amd64_linux/upx $GITHUB_WORKSPACE/upx
- name: Process UI
working-directory: server/ui/template
run: |
yarn
postcss styles.css -o dist/styles.css
cp index.html dist/index.html
- name: Install server dependencies
working-directory: server
run: go get
- name: Pack UI files
working-directory: server
run: packr2
- name: Create build folder
working-directory: server
run: mkdir build
- name: Build Linux binary
working-directory: server
run: go build -ldflags "-s -w -X github.com/rumblefrog/source-chat-relay/server/config.SCRVER=${{ env.SCRVER }} -extldflags '-static'" -o build/linux-server
- name: Build ARMv7 binary
working-directory: server
run: |
export GOARCH=arm
export GOARM=7
go build -ldflags "-s -w -X github.com/rumblefrog/source-chat-relay/server/config.SCRVER=${{ env.SCRVER }} -extldflags '-static'" -o build/armv7-server
- name: Build Windows binary
working-directory: server
run: |
export GOOS=windows
go build -ldflags "-s -w -X github.com/rumblefrog/source-chat-relay/server/config.SCRVER=${{ env.SCRVER }} -extldflags '-static'" -o build/windows-server
- name: Upload server artifact
uses: actions/upload-artifact@v3
with:
name: Server
path: server/build/
client:
name: Build Client
runs-on: ubuntu-latest
strategy:
matrix:
sm-version: ["1.10.x", "1.11.x"]
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Set version env
run: |
echo "SCRVER=$(git describe --always --long --dirty)" >> "$GITHUB_ENV"
- name: Setup SourcePawn Compiler ${{ matrix.sm-version }}
id: setup-sp
uses: rumblefrog/setup-sp@v1.2.2
with:
version: ${{ matrix.sm-version }}
- name: Create external dependency directory
run: mkdir includes
- name: Update version file
working-directory: client
run: envsubst < SCR-Version.inc > SCR-Version.inc.temp && mv SCR-Version.inc.temp SCR-Version.inc
- name: Fetch plugin dependencies
run: |
wget https://raw.githubusercontent.com/nefarius/sm-ext-socket/master/socket.inc -P includes
wget https://raw.githubusercontent.com/rumblefrog/SM-ByteBuffer-Inc/master/bytebuffer.inc -P includes
wget https://www.doctormckay.com/download/scripting/include/morecolors.inc -P includes
- name: Create build folder
run: mkdir build
- name: Compile client against SM ${{ steps.setup-sp.outputs.version }}
run: spcomp64 -iincludes client/Source-Chat-Relay.sp -o build/Source-Chat-Relay.smx
- name: Upload plugin artifact
if: matrix.sm-version == '1.10.x'
uses: actions/upload-artifact@v3
with:
name: Plugin
path: build/
doc:
name: Build Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: "12.22.12"
- name: Export npm bin path
run: export PATH=$PATH:$(npm bin -g)
- name: Install yarn
run: npm i -g yarn
- name: Install dependencies
working-directory: docs
run: yarn
- name: Build documentation
working-directory: docs
run: yarn gatsby build --prefix-paths