From 4db22c0dc4b53f0fa86c8c7e446f67778b83f9f6 Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Tue, 27 Feb 2024 14:59:39 +0100 Subject: [PATCH 01/10] Update Github Actions --- .github/workflows/{gofmt.yml => package.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{gofmt.yml => package.yml} (100%) diff --git a/.github/workflows/gofmt.yml b/.github/workflows/package.yml similarity index 100% rename from .github/workflows/gofmt.yml rename to .github/workflows/package.yml From 94e250768747f0d322e733230f1e7fe6f1a5b2f9 Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Tue, 27 Feb 2024 15:00:14 +0100 Subject: [PATCH 02/10] Update Github Actions --- .github/workflows/package.yml | 44 ++++++++------------ .github/workflows/release.yml | 75 +++++++++++++---------------------- 2 files changed, 43 insertions(+), 76 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 20bb2f7..7899d03 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -1,35 +1,23 @@ -name: gofmt -on: - push: - branches: - - main - pull_request: - paths: - - '.github/workflows/gofmt.yml' - - '**.go' +name: Go package + +on: [push] + jobs: + build: - gofmt: - name: Run gofmt runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - - name: Set up Go 1.17 - uses: actions/setup-go@v5 - with: - go-version: 1.17 - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.21" - - uses: actions/cache@v4 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-gofmt1.17-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-gofmt1.17- + - name: Install dependencies + run: go get . + - name: Build + run: go build -ldflags "-X main.Build=${{ github.ref_name }}" -v ./... - - name: gofmt - run: | - gofmt -s -w ./ + # - name: Test + # run: go test -v ./... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 78e5c5d..b3a3a5e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,62 +1,41 @@ +name: Release + on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]*' + release: + types: [created] -name: Create release and upload binaries +permissions: + contents: write jobs: build: - name: Build + runs-on: ubuntu-latest steps: - - name: Set up Go 1.17 - uses: actions/setup-go@v5 + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 with: - go-version: 1.17 + go-version: "1.21" - - name: Checkout code - uses: actions/checkout@v4 + - name: Install dependencies + run: go get . - name: Build - run: | - mkdir release - CGO_ENABLED=0 go build -ldflags "-X main.Build=${{ github.ref_name }}" -o release/container-manager + run: CGO_ENABLED=0 go build -ldflags "-X main.Build=${{ github.ref_name }}" - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: latest - path: release + - name: Checksum + run: sha256sum container-manager > SHASUM256.txt - release: - name: Create and Upload Release - needs: [ build ] - runs-on: ubuntu-latest - steps: - - name: Download Linux artifacts - uses: actions/download-artifact@v4 - with: - name: latest - path: latest - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - - - name: Upload linux-amd64 - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Test + # run: go test -v ./... + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./latest/container-manager - asset_name: container-manager - asset_content_type: application/octet-stream + files: | + container-manager + SHASUM256.txt + fail_on_unmatched_files: true From 51d69ed427d7a27f1e97a0976139567ff67be286 Mon Sep 17 00:00:00 2001 From: Staal <48656753+staal0@users.noreply.github.com> Date: Wed, 28 Feb 2024 07:15:33 +0100 Subject: [PATCH 03/10] Remove test code Co-authored-by: Simon Bengtsson --- .github/workflows/release.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b3a3a5e..28b57eb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,9 +28,6 @@ jobs: - name: Checksum run: sha256sum container-manager > SHASUM256.txt - # - name: Test - # run: go test -v ./... - - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') From 746660563dbbdcdb7be12d96089fd1ccb913483a Mon Sep 17 00:00:00 2001 From: Staal <48656753+staal0@users.noreply.github.com> Date: Wed, 28 Feb 2024 07:15:41 +0100 Subject: [PATCH 04/10] Remove test code Co-authored-by: Simon Bengtsson --- .github/workflows/package.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 7899d03..0f7c657 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -18,6 +18,3 @@ jobs: run: go get . - name: Build run: go build -ldflags "-X main.Build=${{ github.ref_name }}" -v ./... - - # - name: Test - # run: go test -v ./... From 892546159f7af1e47fc62688072fc836cf3e8c07 Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Wed, 28 Feb 2024 07:37:29 +0100 Subject: [PATCH 05/10] Rename Actions Add Go format check --- .github/workflows/{package.yml => build.yml} | 2 +- .github/workflows/format.yml | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) rename .github/workflows/{package.yml => build.yml} (95%) create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/package.yml b/.github/workflows/build.yml similarity index 95% rename from .github/workflows/package.yml rename to .github/workflows/build.yml index 0f7c657..0b47163 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Go package +name: Build on: [push] diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..73dddbc --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,19 @@ +name: Go format + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.21" + + - name: gofmt + run: | + gofmt -s -w ./ From e6fb0f506b135f20f94b7942c4c70535c9b539ef Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Wed, 28 Feb 2024 07:46:51 +0100 Subject: [PATCH 06/10] Update format.yml to do both lint and format --- .github/workflows/format.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 73dddbc..d7e4034 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,18 +1,15 @@ -name: Go format - +name: Lint and format on: [push] jobs: - build: - + golangci: + name: lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: "1.21" + - uses: actions/setup-go@v5 + - name: golangci-lint + uses: golangci/golangci-lint-action@v4 - name: gofmt run: | From f42f37bda25a1c33953789a141b8c005ec7c16c2 Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Wed, 28 Feb 2024 08:31:18 +0100 Subject: [PATCH 07/10] Fix lint error --- .github/workflows/build.yml | 1 + .github/workflows/format.yml | 3 +++ .github/workflows/release.yml | 1 + 3 files changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b47163..d3ce778 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,7 @@ jobs: uses: actions/setup-go@v4 with: go-version: "1.21" + cache: false - name: Install dependencies run: go get . diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index d7e4034..b356d15 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -8,6 +8,9 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 + with: + go-version: '1.21' + cache: false - name: golangci-lint uses: golangci/golangci-lint-action@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 28b57eb..0ead204 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,7 @@ jobs: uses: actions/setup-go@v4 with: go-version: "1.21" + cache: false - name: Install dependencies run: go get . From fdb8f1c3625a13813ca036615f51037e662a605e Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Wed, 28 Feb 2024 08:41:09 +0100 Subject: [PATCH 08/10] Rename build to release --- .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 0ead204..876db2a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,7 @@ permissions: contents: write jobs: - build: + release: runs-on: ubuntu-latest steps: From a54deb4224034a95d4878551b372789eb0d16b55 Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Wed, 28 Feb 2024 08:54:42 +0100 Subject: [PATCH 09/10] Split lint and format to different Actions --- .github/workflows/format.yml | 9 +++------ .github/workflows/lint.yml | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index b356d15..dc23f6d 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,9 +1,9 @@ -name: Lint and format +name: Go format on: [push] jobs: - golangci: - name: lint + gofmt: + name: format runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -11,9 +11,6 @@ jobs: with: go-version: '1.21' cache: false - - name: golangci-lint - uses: golangci/golangci-lint-action@v4 - - name: gofmt run: | gofmt -s -w ./ diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..0c1b0b3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,15 @@ +name: Go Lint +on: [push] + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + cache: false + - name: golangci-lint + uses: golangci/golangci-lint-action@v4 From af8471d2d8d5b9c188a1c1aad7ab7b9449ac4eab Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Wed, 28 Feb 2024 09:10:11 +0100 Subject: [PATCH 10/10] Use setup-go@v5 --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3ce778..9524f17 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: "1.21" cache: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 876db2a..2f49f15 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: "1.21" cache: false