From 16dd6c8358fad9e46d23771b70030224bc988c6e Mon Sep 17 00:00:00 2001 From: liutianqi Date: Tue, 2 Apr 2024 13:59:58 +0800 Subject: [PATCH] Added some GitHub actions --- .github/workflows/lint.yaml | 29 ++++++++++++++++++++++ .github/workflows/releaser.yaml | 43 +++++++++++++++++++++++++++++++++ .github/workflows/test.yaml | 34 ++++++++++++++++++++++++++ .goreleaser.yml | 38 +++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 .github/workflows/lint.yaml create mode 100644 .github/workflows/releaser.yaml create mode 100644 .github/workflows/test.yaml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..5e7410f --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,29 @@ +name: golangci-lint +on: + push: + tags: + - v* + branches: + - master + - main + pull_request: +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cache-Go + uses: actions/cache@v4 + with: + path: | + ~/go/pkg/mod # Module download cache + ~/.cache/go-build # Build cache (Linux) + ~/Library/Caches/go-build # Build cache (Mac) + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest diff --git a/.github/workflows/releaser.yaml b/.github/workflows/releaser.yaml new file mode 100644 index 0000000..204c8e2 --- /dev/null +++ b/.github/workflows/releaser.yaml @@ -0,0 +1,43 @@ +name: releaser + +on: + push: + tags: + - 'v*.*.*' + +jobs: + goreleaser: + strategy: + matrix: + go-version: [1.20.x] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} + - name: Cache-Go + uses: actions/cache@v4 + with: + path: | + ~/go/pkg/mod # Module download cache + ~/.cache/go-build # Build cache (Linux) + ~/Library/Caches/go-build # Build cache (Mac) + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + - name: Test + run: go test ./... + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..7960ee7 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,34 @@ +on: [push, pull_request] +name: Test +jobs: + test: + strategy: + matrix: + go-version: [1.20.x] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v4 + - name: Cache-Go + uses: actions/cache@v4 + with: + path: | + ~/go/pkg/mod # Module download cache + ~/.cache/go-build # Build cache (Linux) + ~/Library/Caches/go-build # Build cache (Mac) + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + - name: Test + run: go test ./... + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: godoes/dateparse diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..5e9650d --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,38 @@ +project_name: dateparse +builds: + - + id: "dateparse" + binary: "dateparse" + dir: dateparse + - + id: "example" + binary: "example" + dir: example +archives: + - + format_overrides: + - goos: windows + format: zip +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +nfpms: + - + vendor: dateparse + homepage: https://github.com/godoes/dateparse + maintainer: n/a + description: NA + formats: + - apk + - deb + - rpm + release: "1" + section: default + priority: extra \ No newline at end of file