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..b37e9c6 --- /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: stable + - 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..1423905 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,29 +1,125 @@ -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: stable + - 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 + 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