From 1d5a253e374ac17dbd61805e25676c9d9eb8a711 Mon Sep 17 00:00:00 2001 From: marston Date: Thu, 12 Sep 2024 17:55:46 -0400 Subject: [PATCH] adding actions --- .github/dependabot.yml | 10 ++++++ .github/workflows/build.yml | 18 ++++++++++ .github/workflows/golangci.yml | 27 +++++++++++++++ .github/workflows/release.yml | 60 +++++++++++++++++++++++++++++++++ .github/workflows/test-unit.yml | 19 +++++++++++ 5 files changed, 134 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/golangci.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test-unit.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..bc9503b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + - package-ecosystem: gomod + directory: "/" + schedule: + interval: daily diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a1d11c6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,18 @@ +name: Build + +on: + pull_request: + push: + branches: ["main"] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.7 + - uses: actions/setup-go@v5 + with: + go-version: 1.23 # The Go version to download (if necessary) and use. + - name: Build CLI + run: go install diff --git a/.github/workflows/golangci.yml b/.github/workflows/golangci.yml new file mode 100644 index 0000000..73310d0 --- /dev/null +++ b/.github/workflows/golangci.yml @@ -0,0 +1,27 @@ +name: golangci-lint +on: + push: + tags: + - v* + branches: + - main + pull_request: +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v5 + with: + go-version: 1.23 + - uses: actions/checkout@v4.1.7 + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: latest + args: --timeout 10m diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a9a394e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Release + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v20.15.10 + - "v[0-9]+.[0-9]+.[0-9]+.?[0-9]*" # Push events to matching v*, v20.15.10.1 + - "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" # Push events to matching alpha releases + - "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+" # Push events to matching beta releases + - "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+" # Push events to matching release candidates + + +jobs: + native-build-cli: + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [ubuntu-20.04, macos-latest] + steps: + - uses: actions/checkout@v4.1.7 + - uses: actions/setup-go@v5 + with: + go-version: 1.23 # The Go version to download (if necessary) and use. + - name: Build CLI + shell: bash + run: | + make build + cp "build/mulberry" "mulberry-$RUNNER_OS" + - uses: actions/upload-artifact@v4 + with: + name: mulberry-${{runner.os}} + path: mulberry-${{runner.os}} + + Release: + needs: + [native-build-cli] + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4.1.7 + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/} + - name: Declare Commit Variables + id: is_pre_release + shell: bash + run: | + echo "::set-output name=IS_PRE_RELEASE::$(echo "${{ steps.get_version.outputs.VERSION }}" | awk 'BEGIN{prerelease="false"} /beta|alpha/{prerelease="true"} END{print prerelease}')" + - uses: actions/download-artifact@v4 + with: + name: mulberry-Linux + - uses: actions/download-artifact@v4 + with: + name: mulberry-macOS + - name: Release + uses: softprops/action-gh-release@v2 + with: + prerelease: ${{ steps.is_pre_release.outputs.IS_PRE_RELEASE }} + files: | + mulberry-macOS + mulberry-Linux diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml new file mode 100644 index 0000000..3e51d1c --- /dev/null +++ b/.github/workflows/test-unit.yml @@ -0,0 +1,19 @@ +name: Unit Test + +on: + pull_request: + push: + branches: ["main"] + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.7 + - uses: actions/setup-go@v5 + with: + go-version: 1.23 # The Go version to download (if necessary) and use. + - name: Test + shell: bash + run: make test-unit