diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..5c79a36b --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,23 @@ +name: Build +on: pull_request +jobs: + build: + strategy: + matrix: + os: + - ubuntu-latest + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: "^1.17" + - name: Set up environment + run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: build --snapshot --rm-dist diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..f86093dc --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,61 @@ +name: Release +on: + push: + branches: + - main +jobs: + tag: + runs-on: ubuntu-latest + outputs: + new-tag: ${{ steps.bump-tag.outputs.new }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Configure Git + run: | + git config --global user.name "$GITHUB_ACTOR" + git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: "^1.17" + - name: Install ccv + run: > + curl -sSL https://github.com/smlx/ccv/releases/download/v0.3.2/ccv_0.3.2_linux_amd64.tar.gz + | sudo tar -xz -C /usr/local/bin ccv + - name: Bump tag if necessary + id: bump-tag + run: | + if [ -z $(git tag -l $(ccv)) ]; then + git tag $(ccv) + git push --tags + echo "::set-output name=new::true" + fi + release: + needs: tag + if: needs.tag.outputs.new-tag == 'true' + strategy: + matrix: + os: + - ubuntu-latest + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: "^1.17" + - name: Set up environment + run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tag-to-release.yaml b/.github/workflows/tag-to-release.yaml new file mode 100644 index 00000000..5fe339d6 --- /dev/null +++ b/.github/workflows/tag-to-release.yaml @@ -0,0 +1,28 @@ +name: Tag to Release +on: + push: + tags: + - v* +jobs: + release: + strategy: + matrix: + os: + - ubuntu-latest + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: "^1.17" + - name: Set up environment + run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + 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 00000000..f2fc8eb5 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,14 @@ +name: Test +on: pull_request +jobs: + go-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: "^1.17" + - name: Run Tests + run: go test -v ./... diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..ebe1fbe2 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,8 @@ +builds: +- dir: . + ldflags: + - > + -s -w -X main.date={{.Date}} -X "main.goVersion={{.Env.GOVERSION}}" + -X main.shortCommit={{.ShortCommit}} -X main.version={{.Version}} + env: + - CGO_ENABLED=0