Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
BSD Runner test
  • Loading branch information
mihakralj committed Aug 8, 2023
1 parent 67104c0 commit 7a86404
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 9 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/bsd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test

on:
workflow_dispatch:

jobs:
test:
runs-on: macos-12
name: A job to run test in FreeBSD
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Extract version from Makefile
id: extract_version
run: echo "VERSION=$(awk -F '=' '/^VERSION/ {print $2}' Makefile)" >> $GITHUB_ENV
shell: bash

- name: Compile in FreeBSD
id: compile
uses: vmactions/[email protected]
with:
envs: 'VERSION=${{ env.VERSION }}'
usesh: true
prepare: |
pkg install -y curl wget
run: |
pwd
ls -lah
whoami
env
freebsd-version
name=$(curl -s https://go.dev/dl/ | grep 'freebsd-amd64' | sed -n 's/.*href="\([^"]*\)".*/\1/p' | head -n 1 | xargs basename)
wget -q "https://dl.google.com/go/$name"
tar -C /usr/local -xzf "$name"
mkdir ~/.gopkg
export GOPATH=/root/.gopkg
export PATH=$PATH:/usr/local/go/bin:/root/.gopkg/bin
go build -gcflags='-trimpath' -ldflags="-s -w -X cmd.Version=${VERSION}" opnsense.go
ls -l
mkdir -p /Users/runner/work/opnsense-cli/opnsense-cli/work-dir/usr/local/bin
cp /Users/runner/work/opnsense-cli/opnsense-cli/opnsense /Users/runner/work/opnsense-cli/opnsense-cli/work-dir/usr/local/bin/
ls -l /Users/runner/work/opnsense-cli/opnsense-cli/work-dir/usr/local/bin/
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go build -o ./bin/opnsense-${{ matrix.goos }}
go build -ldflags "-X cmd.Version=${{ steps.extract_version.outputs.version }}" -o ./bin/opnsense-${{ matrix.goos }}
- name: Upload all artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
with:
prerelease: true
tag_name: ${{ needs.build.outputs.version }}
name: Release ${{ needs.build.outputs.version }}
name: opnsense-cli ${{ needs.build.outputs.version }}
files: |
./opnsense-bsd
./opnsense-mac
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
opnsense.exe

test/
build/
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ build: deps
@echo "Building..."
ifeq ($(OS),Windows_NT)
@if not exist $(BUILD_DIR) mkdir $(BUILD_DIR)
@$(GO) build -ldflags "-X main.version=$(VERSION)" -o $(BUILD_DIR)/$(BINARY_NAME).exe .
@$(GO) build -ldflags "-X cmd.version=$(VERSION)" -o $(BUILD_DIR)/$(BINARY_NAME).exe .
else
@mkdir -p $(BUILD_DIR)
@$(GO) build -ldflags "-X main.version=$(VERSION)" -o $(BUILD_DIR)/$(BINARY_NAME) .
@$(GO) build -ldflags "-X cmd.version=$(VERSION)" -o $(BUILD_DIR)/$(BINARY_NAME) .
endif

# Run tests
Expand Down
Binary file removed build/opnsense-fbsd
Binary file not shown.
Binary file removed build/opnsense-lnx
Binary file not shown.
Binary file removed build/opnsense-mac
Binary file not shown.
6 changes: 1 addition & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

var (
version = "0.1.0"
Version string
verbose int
force bool
host string
Expand Down Expand Up @@ -64,7 +64,3 @@ func Execute() {
os.Exit(1)
}
}

func Version(ver string) {
version = ver
}

0 comments on commit 7a86404

Please sign in to comment.