From 9daea7acfafe801951c2facc45afd696af19bf7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Sun, 5 May 2024 15:13:03 +0200 Subject: [PATCH 1/8] Faster CI checkout --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e3d55e2..986752d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Go uses: actions/setup-go@v4 From 0ce111df3f655410a66e8bd10c0558a120a75672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Sun, 5 May 2024 15:13:51 +0200 Subject: [PATCH 2/8] Read go version from go.mod --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 986752d..1cdecdb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,9 @@ jobs: - name: Setup Go uses: actions/setup-go@v4 with: - go-version: 1.20.x + go-version-file: 'go.mod' + check-latest: true + cache: true - name: Install dependencies run: go get . From 33d9671544640fbf7caa3da12ba0c2a97fae31fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Sun, 5 May 2024 15:14:03 +0200 Subject: [PATCH 3/8] Run linter and tests --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1cdecdb..a5ac6db 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,8 +22,8 @@ jobs: check-latest: true cache: true - - name: Install dependencies - run: go get . + - name: Run linter and tests + run: go test -v -vet='all' ./... - name: Build windows/amd64 run: GOOS=windows GOARCH=amd64 go build -o ChunkCleaner-Win64.exe From 0c60bff19b0b6b1b54a211e6a0f3a9a8cc0984e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Sun, 5 May 2024 15:19:51 +0200 Subject: [PATCH 4/8] ignore build output --- .gitignore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 12feb64..2050d80 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# +/ChunkCleaner-Linux64 +/ChunkCleaner-Win64.exe + # Binaries for programs and plugins *.exe *.exe~ @@ -22,4 +22,4 @@ go.work # User-specific stuff .idea/ -*.iml \ No newline at end of file +*.iml From 46d5dd976715de7c72810063f38d7f41e99b9dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Sun, 5 May 2024 15:20:43 +0200 Subject: [PATCH 5/8] update actions/setup-go --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5ac6db..30589fa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: fetch-depth: 0 - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version-file: 'go.mod' check-latest: true From 631dd643c46877b60e0a26152914550087517080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Sun, 5 May 2024 15:21:49 +0200 Subject: [PATCH 6/8] Always run linter and tests but skip release without tag --- .github/workflows/release.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 30589fa..7743333 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,6 @@ name: Release -on: - push: - tags: - - "*" +on: [ push, pull_request ] jobs: build: @@ -26,16 +23,15 @@ jobs: run: go test -v -vet='all' ./... - name: Build windows/amd64 + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') == true run: GOOS=windows GOARCH=amd64 go build -o ChunkCleaner-Win64.exe - name: Build linux/amd64 - run: GOOS=linux GOARCH=amd64 go build -o ChunkCleaner-Linux64 -v ./... - - - name: Debug - List files - run: | - ls ${{ github.workspace }} + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') == true + run: GOOS=linux GOARCH=amd64 go build -o ChunkCleaner-Linux64 - name: Release + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') == true uses: marvinpinto/action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" From 33ad5bfb3c3309047e90bcdef402363123d28e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Sun, 5 May 2024 15:24:41 +0200 Subject: [PATCH 7/8] Workflow name --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7743333..b88997b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release +name: '🧑‍🏭' on: [ push, pull_request ] From 08744f1602726da186a8305a6dcb3d9732672c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Sun, 5 May 2024 15:27:11 +0200 Subject: [PATCH 8/8] Use separate jobs for checks and release --- .github/workflows/release.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b88997b..32b0548 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,11 @@ name: '🧑‍🏭' on: [ push, pull_request ] jobs: - build: - runs-on: ubuntu-latest + check: + runs-on: ubuntu-22.04 steps: + - name: Checkout uses: actions/checkout@v4 with: @@ -22,16 +23,31 @@ jobs: - name: Run linter and tests run: go test -v -vet='all' ./... + release: + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') == true + needs: check + runs-on: ubuntu-22.04 + steps: + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + check-latest: true + cache: true + - name: Build windows/amd64 - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') == true run: GOOS=windows GOARCH=amd64 go build -o ChunkCleaner-Win64.exe - name: Build linux/amd64 - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') == true run: GOOS=linux GOARCH=amd64 go build -o ChunkCleaner-Linux64 - name: Release - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') == true uses: marvinpinto/action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}"