From 95caed9b33616d83bbeb0ac183776865e7db8b84 Mon Sep 17 00:00:00 2001 From: Justin Harms Date: Sun, 10 Mar 2024 14:04:10 -0500 Subject: [PATCH 1/5] fyne cant follow golangs example with getting deps for builds --- .gitea/workflows/build.yaml | 3 +++ .gitea/workflows/pr-validation.yaml | 3 +++ .gitea/workflows/release-tag.yaml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 64a1fd9..08579ad 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -30,6 +30,9 @@ jobs: go get fyne.io/fyne/v2@latest go install fyne.io/fyne/v2/cmd/fyne@latest + - name: go mod + run: go mod tidy + - name: build linux run: | BUILD=${{github.run_number}} diff --git a/.gitea/workflows/pr-validation.yaml b/.gitea/workflows/pr-validation.yaml index 983834d..92506ec 100644 --- a/.gitea/workflows/pr-validation.yaml +++ b/.gitea/workflows/pr-validation.yaml @@ -30,6 +30,9 @@ jobs: go get fyne.io/fyne/v2@latest go install fyne.io/fyne/v2/cmd/fyne@latest + - name: go mod + run: go mod tidy + - name: build run: | GOOS=linux diff --git a/.gitea/workflows/release-tag.yaml b/.gitea/workflows/release-tag.yaml index 4927422..86d1f9d 100644 --- a/.gitea/workflows/release-tag.yaml +++ b/.gitea/workflows/release-tag.yaml @@ -26,6 +26,9 @@ jobs: go get fyne.io/fyne/v2@latest go install fyne.io/fyne/v2/cmd/fyne@latest + - name: go mod + run: go mod tidy + - name: build linux run: | VERSION=${{github.ref_name}} From 8de631afa2d92204d8151619d4d1fa5528b0ebb3 Mon Sep 17 00:00:00 2001 From: Justin Harms Date: Sun, 10 Mar 2024 15:12:00 -0500 Subject: [PATCH 2/5] no need to checkout the entire repo --- .gitea/workflows/build.yaml | 3 --- .gitea/workflows/pr-validation.yaml | 2 -- .gitea/workflows/release-tag.yaml | 2 -- 3 files changed, 7 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 08579ad..da1b938 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -3,7 +3,6 @@ on: push: branches: - "master" - - "develop" jobs: build: @@ -14,8 +13,6 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: setup go uses: actions/setup-go@v5 with: diff --git a/.gitea/workflows/pr-validation.yaml b/.gitea/workflows/pr-validation.yaml index 92506ec..c0752a5 100644 --- a/.gitea/workflows/pr-validation.yaml +++ b/.gitea/workflows/pr-validation.yaml @@ -14,8 +14,6 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: setup go uses: actions/setup-go@v5 with: diff --git a/.gitea/workflows/release-tag.yaml b/.gitea/workflows/release-tag.yaml index 86d1f9d..11b1630 100644 --- a/.gitea/workflows/release-tag.yaml +++ b/.gitea/workflows/release-tag.yaml @@ -10,8 +10,6 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: setup go uses: actions/setup-go@v5 with: From 4c1de974f0afd935f4ba308e1a4a9b245fe8243d Mon Sep 17 00:00:00 2001 From: Justin Harms Date: Sun, 10 Mar 2024 16:10:59 -0500 Subject: [PATCH 3/5] major ci change --- .gitea/workflows/build.yaml | 56 --------------- .gitea/workflows/ci.yaml | 104 ++++++++++++++++++++++++++++ .gitea/workflows/pr-validation.yaml | 53 -------------- .gitea/workflows/release-tag.yaml | 32 ++++----- 4 files changed, 119 insertions(+), 126 deletions(-) delete mode 100644 .gitea/workflows/build.yaml create mode 100644 .gitea/workflows/ci.yaml delete mode 100644 .gitea/workflows/pr-validation.yaml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml deleted file mode 100644 index da1b938..0000000 --- a/.gitea/workflows/build.yaml +++ /dev/null @@ -1,56 +0,0 @@ -name: build and test -on: - push: - branches: - - "master" - -jobs: - build: - name: artifact builds on linux and windows - env: - RUNNER_TOOL_CACHE: /toolcache - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - name: setup go - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - name: setup-dependencies - run: | - apt-get update - apt-get install -y gcc-mingw-w64 gcc libgl1-mesa-dev xorg-dev - - - name: get fyne - run: | - go get fyne.io/fyne/v2@latest - go install fyne.io/fyne/v2/cmd/fyne@latest - - - name: go mod - run: go mod tidy - - - name: build linux - run: | - BUILD=${{github.run_number}} - GOOS=windows - GOARCH=amd64 - GOFLAGS="-ldflags=-s -ldflags=-w" - CGO_ENABLED=1 - CC=gcc - fyne package --appBuild=${BUILD} --exe bin/swiped-mod-switcher-$VERSION-linux-amd64 main.go - - - name: build windows - run: | - BUILD=${{github.run_number}} - GOOS=windows - GOARCH=amd64 - GOFLAGS="-ldflags=-H=windowsgui -ldflags=-s -ldflags=-w" - CGO_ENABLED=1 - CC=x86_64-w64-mingw32-gcc - fyne package --appBuild=${BUILD} --exe bin/swiped-mod-switcher-$VERSION-windows-amd64.exe main.go - - - uses: actions/upload-artifact@v3 - with: - name: swiped-mod-switcher-${{github.ref_name}} - path: bin/ \ No newline at end of file diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..a83a1a9 --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,104 @@ +name: CI +on: + push: + branches: [master, develop] + pull_request: + +jobs: + lint: + name: Lint + env: + RUNNER_TOOL_CACHE: /toolcache + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + check-latest: true + cache: true + + - name: Lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest + args: --verbose + + test: + name: Test + env: + RUNNER_TOOL_CACHE: /toolcache + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + check-latest: true + cache: true + + - name: Test + run: go test -race -v -shuffle=on ./... + + build: + name: Build + env: + RUNNER_TOOL_CACHE: /toolcache + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + check-latest: true + cache: true + + - name: Setup OS dependencies + run: | + apt-get update + apt-get install -y gcc-mingw-w64 gcc libgl1-mesa-dev xorg-dev + + - name: Get fyne command + run: | + go install fyne.io/fyne/v2/cmd/fyne@latest + + - name: Get go dependencies + run: | + go mod tidy + + - name: Build for linux + run: | + fyne package --appBuild=${BUILD} --exe bin/swiped-mod-switcher-${VERSION}.${BUILD}-${GOOS}-${GOARCH}${EXE} main.go + env: + BUILD: ${{github.run_number}} + GOOS: linux + GOARCH: amd64 + EXE: "" + CGO_ENABLED: 1 + CC: gcc + + - name: Build for windows + run: | + fyne package --appBuild=${BUILD} --exe bin/swiped-mod-switcher-${VERSION}.${BUILD}-${GOOS}-${GOARCH}${EXE} main.go + env: + BUILD: ${{github.run_number}} + GOOS: windows + GOARCH: amd64 + EXE: .exe + CGO_ENABLED: 1 + CC: gcc + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: swiped-mod-switcher-${{github.ref_name}} + path: bin/ \ No newline at end of file diff --git a/.gitea/workflows/pr-validation.yaml b/.gitea/workflows/pr-validation.yaml deleted file mode 100644 index c0752a5..0000000 --- a/.gitea/workflows/pr-validation.yaml +++ /dev/null @@ -1,53 +0,0 @@ -name: pull request validation -on: - pull_request: - branches: - - master - - develop - -jobs: - build: - name: build and run tests - env: - RUNNER_TOOL_CACHE: /toolcache - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - name: setup go - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - name: setup dependencies - run: | - apt-get update - apt-get install -y gcc-mingw-w64 gcc libgl1-mesa-dev xorg-dev - - - name: get fyne - run: | - go get fyne.io/fyne/v2@latest - go install fyne.io/fyne/v2/cmd/fyne@latest - - - name: go mod - run: go mod tidy - - - name: build - run: | - GOOS=linux - GOARCH=amd64 - GOFLAGS="-ldflags=-s -ldflags=-w" - CGO_ENABLED=1 - CC=gcc - fyne package --exe bin/swiped-mod-switcher-${VERSION}.${BUILD}-linux-amd64 main.go - - 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 index 11b1630..9af8d8b 100644 --- a/.gitea/workflows/release-tag.yaml +++ b/.gitea/workflows/release-tag.yaml @@ -1,4 +1,4 @@ -name: release-tag +name: Release versioned tag on: push: tags: @@ -6,52 +6,50 @@ on: jobs: release: + name: Build versioned release runs-on: ubuntu-latest steps: - - name: checkout + - name: Checkout uses: actions/checkout@v4 - - name: setup go + + - name: Setup go uses: actions/setup-go@v5 with: go-version-file: 'go.mod' - - name: setup-dependencies + + - name: Setup OS dependencies run: | apt-get update apt-get install -y gcc-mingw-w64 gcc libgl1-mesa-dev xorg-dev - - name: get fyne + - name: Install fyne command run: | - go get fyne.io/fyne/v2@latest go install fyne.io/fyne/v2/cmd/fyne@latest - - name: go mod + - name: Install go dependencies run: go mod tidy - - name: build linux + - name: Build for linux run: | VERSION=${{github.ref_name}} BUILD=${{github.run_number}} - GOOS=linux - GOARCH=amd64 GOFLAGS="-ldflags=-s -ldflags=-w" CGO_ENABLED=1 CC=gcc - fyne package --appVersion=${VERSION#v} --appBuild=${BUILD} --exe bin/sw1ped-mod-switcher-${VERSION}.${BUILD}-linux-amd64 main.go + fyne package --os linux --release --appVersion=${VERSION#v} --appBuild=${BUILD} --exe bin/sw1ped-mod-switcher-${VERSION}.${BUILD}-linux-amd64 main.go - - name: build windows + - name: Build for windows run: | VERSION=${{github.ref_name}} BUILD=${{github.run_number}} - GOOS=windows - GOARCH=amd64 GOFLAGS="-ldflags=-H=windowsgui -ldflags=-s -ldflags=-w" CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc - fyne package --appVersion=${VERSION#v} --appBuild=${BUILD} --exe bin/sw1ped-mod-switcher-${VERSION}.${BUILD}-windows-amd64.exe main.go + fyne package --os windows --release --appVersion=${VERSION#v} --appBuild=${BUILD} --exe bin/sw1ped-mod-switcher-${VERSION}.${BUILD}-windows-amd64.exe main.go - - name: add release binaries + - name: Release binaries uses: https://gitea.com/actions/release-action@main with: files: |- - bin/** + bin/** api_key: '${{secrets.RELEASE_TOKEN}}' From 57d8c1b33012fd5bb1b290a55647e3e35f4db60d Mon Sep 17 00:00:00 2001 From: Justin Harms Date: Sun, 10 Mar 2024 16:24:56 -0500 Subject: [PATCH 4/5] fix test and build ci --- .gitea/workflows/ci.yaml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index a83a1a9..05f15b3 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -43,6 +43,19 @@ jobs: check-latest: true cache: true + - name: Setup OS dependencies + run: | + apt-get update + apt-get install -y gcc-mingw-w64 gcc libgl1-mesa-dev xorg-dev + + - name: Get fyne command + run: | + go install fyne.io/fyne/v2/cmd/fyne@latest + + - name: Get go dependencies + run: | + go mod tidy + - name: Test run: go test -race -v -shuffle=on ./... @@ -95,7 +108,7 @@ jobs: GOARCH: amd64 EXE: .exe CGO_ENABLED: 1 - CC: gcc + CC: x86_64-w64-mingw64-gcc - name: Upload artifact uses: actions/upload-artifact@v3 From 89dedb9870495c6a6c0e658a230d863d9cafcf3b Mon Sep 17 00:00:00 2001 From: Justin Harms Date: Sun, 10 Mar 2024 16:36:44 -0500 Subject: [PATCH 5/5] oops --- .gitea/workflows/ci.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 05f15b3..4c54917 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -7,6 +7,13 @@ on: jobs: lint: name: Lint + permissions: + # Required: allow read access to the content for analysis. + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + pull-requests: read + # Optional: Allow write access to checks to allow the action to annotate code in the PR. + checks: write env: RUNNER_TOOL_CACHE: /toolcache runs-on: ubuntu-latest @@ -108,7 +115,7 @@ jobs: GOARCH: amd64 EXE: .exe CGO_ENABLED: 1 - CC: x86_64-w64-mingw64-gcc + CC: x86_64-w64-mingw32-gcc - name: Upload artifact uses: actions/upload-artifact@v3