From b5db2535c493debf48008a2224b52ea2088e02be Mon Sep 17 00:00:00 2001 From: Jelloeater Date: Fri, 8 Nov 2024 13:46:08 -0500 Subject: [PATCH 1/5] feat: Added Auto release workflows --- .github/workflows/go.yml | 27 ------- .github/workflows/nightly.yml | 118 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 143 ++++++++++++++++++++++++++++------ 3 files changed, 238 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/go.yml create mode 100644 .github/workflows/nightly.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index b163c61..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Go test - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - build: - env: - GO111MODULE: auto - runs-on: ubuntu-latest - strategy: - matrix: - go-version: ["1.22", "1.23"] - - steps: - - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Build - run: go build - - name: Test - run: go test -v . diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..52533fb --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,118 @@ +name: Test + +on: + push: + branches: [main] + pull_request: + branches: [main] + + + +permissions: + contents: write + packages: write + issues: write + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.22.0 + - name: Install dependencies + run: go mod download + - name: Run tests + run: go test -v . + + + goreleaser: + runs-on: ubuntu-latest + needs: + - test + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: stable + + - name: Install Deps + run: | + sudo apt-get install tree git-extras -y + + - name: Release config + run: | + cat << EOF > /tmp/goreleaser-github.yaml + project_name: tz + version: 2 + builds: + - env: [CGO_ENABLED=0] + goos: + - linux + - windows + - darwin + - freebsd + - openbsd + goarch: + - 386 + - amd64 + - arm + - arm64 + nfpms: + - + maintainer: Arnaud Berthomier + bindir: /usr/local/bin + description: A time zone helper + homepage: https://github.com/oz/tz + license: GPL-3 + formats: + - deb + - rpm + - apk + - termux.deb + - archlinux + - ipk + EOF + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + # 'latest', 'nightly', or a semver + version: "~> v2" + args: release --clean --verbose --snapshot --config /tmp/goreleaser-github.yaml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: List Dist + run: | + tree dist + + - name: Add changelog + run: | + git-changelog -a -x -t >> dist/CHANGELOG.md + + - name: Generate artifact name + id: artifact_name + run: | + REPO_NAME=${GITHUB_REPOSITORY##*/} + SHORT_SHA=${GITHUB_SHA::7} + ARTIFACT_NAME="${REPO_NAME}-${GITHUB_REF_NAME}-${SHORT_SHA}" + echo "name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT + + - name: Upload Dist + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.artifact_name.outputs.name }} + path: dist/* + retention-days: 14 + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 611d1a3..102d12a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,29 +1,126 @@ -name: Build Go Binaries for new releases +name: Release on: - release: - types: [created] + push: + # run only against tags + tags: + - "*" + +permissions: + contents: write + packages: write + issues: write jobs: - releases-matrix: - name: Build Go Binaries + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.22.0 + - name: Install dependencies + run: go mod download + - name: Run tests + run: go test -v ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./... + + goreleaser: + needs: + - test runs-on: ubuntu-latest - strategy: - matrix: - goos: [linux, windows, darwin, openbsd, netbsd, freebsd] - goarch: ["amd64", "arm", "arm64"] - exclude: - - goarch: arm - goos: darwin - - goarch: arm64 - goos: windows steps: - - uses: actions/checkout@v4 - - uses: wangyoucao577/go-release-action@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: ${{ matrix.goos }} - goarch: ${{ matrix.goarch }} - sha256sum: true - md5sum: false - extra_files: COPYING + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: stable + + - name: Release config + run: | + cat << EOF > /tmp/goreleaser-github.yaml + project_name: tz + version: 2 + builds: + - env: [CGO_ENABLED=0] + goos: + - linux + - windows + - darwin + - freebsd + - openbsd + - android + goarch: + - 386 + - amd64 + - arm + - arm64 + nfpms: + - + maintainer: Arnaud Berthomier + bindir: /usr/local/bin + description: A time zone helper + homepage: https://github.com/oz/tz + license: GPL-3 + formats: + - deb + - rpm + - apk + - termux.deb + - archlinux + - ipk + + release: + draft: false # If set to true, will not auto-publish the release. + replace_existing_draft: true + replace_existing_artifacts: true + target_commitish: "{{ .Commit }}" + prerelease: auto + + make_latest: true + mode: replace + include_meta: true + + EOF + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + # 'latest', 'nightly', or a semver + version: "~> v2" + args: release --clean --verbose --config /tmp/goreleaser-github.yaml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: List Dist + run: | + sudo apt-get install tree -y + tree dist + + - name: Upload .deb artifact x86 + uses: actions/upload-artifact@v3 + with: + name: deb-package + path: dist/*amd64.deb + - name: Upload .deb artifact ARM + uses: actions/upload-artifact@v3 + with: + name: deb-package-arm + path: dist/*arm64.deb + - name: Upload .rpm artifact x86 + uses: actions/upload-artifact@v3 + with: + name: rpm-package + path: dist/*amd64.rpm + - name: Upload .apk artifact x86 + uses: actions/upload-artifact@v3 + with: + name: apk-package + path: dist/*amd64.apk From b6eaa52f1d4b6cc918e5b938f17584b026566fe5 Mon Sep 17 00:00:00 2001 From: Jelloeater Date: Fri, 8 Nov 2024 14:16:35 -0500 Subject: [PATCH 2/5] Removed broken Android builder --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 102d12a..b8a2fc3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,7 +55,6 @@ jobs: - darwin - freebsd - openbsd - - android goarch: - 386 - amd64 From 5ce9f39c770363018f8ebc06ec4e98491d2ab5b2 Mon Sep 17 00:00:00 2001 From: Jelloeater Date: Tue, 26 Nov 2024 16:59:17 -0500 Subject: [PATCH 3/5] Update nightly.yml --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 52533fb..8a5b297 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -24,7 +24,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.22.0 + go-version: 'stable' - name: Install dependencies run: go mod download - name: Run tests From 39203e10b3730dc1e866b5127227c4ff078b572d Mon Sep 17 00:00:00 2001 From: Jelloeater Date: Tue, 26 Nov 2024 16:59:50 -0500 Subject: [PATCH 4/5] Update release.yml --- .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 b8a2fc3..1423905 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.22.0 + go-version: stable - name: Install dependencies run: go mod download - name: Run tests From d6476813d0af4a2fe783bcf88e31b374e91e5be8 Mon Sep 17 00:00:00 2001 From: Jelloeater Date: Tue, 26 Nov 2024 17:00:03 -0500 Subject: [PATCH 5/5] Update nightly.yml --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 8a5b297..b37e9c6 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -24,7 +24,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: stable - name: Install dependencies run: go mod download - name: Run tests