From 58bb19b43f4299a926c18234a76d9310b5fc1ce7 Mon Sep 17 00:00:00 2001 From: Justin Harms Date: Sun, 10 Mar 2024 00:41:03 -0600 Subject: [PATCH] add actions --- .gitea/workflows/build.yaml | 28 ++++++++++++++++++++++ .gitea/workflows/pr-validation.yaml | 37 +++++++++++++++++++++++++++++ .gitea/workflows/release-tag.yaml | 32 +++++++++++++++++++++++++ build.cmd | 2 +- main.go | 4 +++- 5 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/build.yaml create mode 100644 .gitea/workflows/pr-validation.yaml create mode 100644 .gitea/workflows/release-tag.yaml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..9c297bb --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,28 @@ +name: Build and Artifact Vulture +on: + push: + branches: + - "master" + - "develop" + +jobs: + build: + env: + RUNNER_TOOL_CACHE: /toolcache + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: setup-dependencies + run: | + apt install mingw-w64 gcc + - name: build-linux + run: | + GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=gcc go build -v -ldflags="-s -w -X 'main.Version=${{github.ref_name}}'" -o bin/sw1ped-mod-switcher-${{github.ref_name}}-linux-amd64 + - name: build-windows + run: | + GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw64-gcc go build -v -ldflags="-s -w -X 'main.Version=${{github.ref_name}}'" -o bin/sw1ped-mod-switcher-${{github.ref_name}}-windows-amd64.exe \ No newline at end of file diff --git a/.gitea/workflows/pr-validation.yaml b/.gitea/workflows/pr-validation.yaml new file mode 100644 index 0000000..07acf91 --- /dev/null +++ b/.gitea/workflows/pr-validation.yaml @@ -0,0 +1,37 @@ +name: PR Validation +on: + pull_request: + branches: + - master + - develop + +jobs: + build: + name: Build and Test Vulture + env: + RUNNER_TOOL_CACHE: /toolcache + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: setup-dependencies + run: | + apt install mingw-w64 gcc + - name: Build + run: go build -v ./... + - name: Run Tests + run: go test -v ./... + - name: Check Vet + run: go vet ./... + - name: Check Formatting + run: | + gofmt -s -l . + if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi + - name: Check Lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest \ No newline at end of file diff --git a/.gitea/workflows/release-tag.yaml b/.gitea/workflows/release-tag.yaml new file mode 100644 index 0000000..119c484 --- /dev/null +++ b/.gitea/workflows/release-tag.yaml @@ -0,0 +1,32 @@ +name: release + +on: + push: + tags: + - '*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: setup-dependencies + run: | + apt install mingw-w64 gcc + - name: release-build-linux + run: GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X 's1d3sw1ped/vulture/config.BuildVersion=${{github.ref_name}}'" -o bin/vulture-${{github.ref_name}}-linux-amd64 + - name: release-build-windows + run: GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X 's1d3sw1ped/vulture/config.BuildVersion=${{github.ref_name}}'" -o bin/vulture-${{github.ref_name}}-windows-amd64.exe + - name: release-build-darwin + run: GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X 's1d3sw1ped/vulture/config.BuildVersion=${{github.ref_name}}'" -o bin/vulture-${{github.ref_name}}-darwin-amd64 + - name: update-release + uses: https://gitea.com/actions/release-action@main + with: + files: |- + bin/** + api_key: '${{secrets.RELEASE_TOKEN}}' diff --git a/build.cmd b/build.cmd index 6757e4e..c7813dc 100644 --- a/build.cmd +++ b/build.cmd @@ -1 +1 @@ -fyne package -os windows -icon .\cpms.png \ No newline at end of file +fyne package --os windows --icon .\cpms.png --exe SwipedModSwitcher \ No newline at end of file diff --git a/main.go b/main.go index 4c7a003..ae72b66 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,8 @@ import ( "gopkg.in/yaml.v3" ) +var Version = "" + type Config struct { ModProfilesDirectory string `yaml:"mod_profiles_dir"` GameModsDirectory string `yaml:"game_mods_dir"` @@ -69,7 +71,7 @@ func main() { cfg = loadConfig() ap := app.New() - wp := ap.NewWindow("Swiped Mod Switcher") + wp := ap.NewWindow("Swiped Mod Switcher " + Version) wp.Resize(fyne.NewSize(600, 1)) wp.CenterOnScreen()