diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 6ca07209..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,174 +0,0 @@ -version: 2.1 -workflows: - pr_acceptance: - jobs: - - test - - build - build_accept_deploy: - jobs: - - test - - build - - package: - requires: - - build - - deploy: - requires: - - test - - build - - package - publish_release: - jobs: - - test: - filters: - branches: - ignore: /.*/ - tags: - only: /v[0-9]+(\.[0-9]+)*(-.*)*/ - - build: - requires: - - test - filters: - branches: - ignore: /.*/ - tags: - only: /v[0-9]+(\.[0-9]+)*(-.*)*/ - - package: - requires: - - test - - build - filters: - branches: - ignore: /.*/ - tags: - only: /v[0-9]+(\.[0-9]+)*(-.*)*/ - - deploy: - requires: - - test - - build - - package - filters: - branches: - ignore: /.*/ - tags: - only: /v[0-9]+(\.[0-9]+)*(-.*)*/ - - github_binaries: - requires: - - test - - build - - package - - deploy - filters: - branches: - ignore: /.*/ - tags: - only: /v[0-9]+(\.[0-9]+)*(-.*)*/ - -jobs: - test: - working_directory: /home/circleci/go/src/github.com/grafana/carbon-relay-ng - docker: - - image: cimg/go:1.21.8 - steps: - - checkout - - run: make test - - build: - working_directory: /home/circleci/go/src/github.com/grafana/carbon-relay-ng - docker: - - image: cimg/go:1.21.8 - steps: - - checkout - - run: go install github.com/go-bindata/go-bindata/...@latest - - run: make LINUX_PACKAGE_GOARCH=amd64 build-linux - - run: make LINUX_PACKAGE_GOARCH=arm64 build-linux - # note, build-linux runs go-bindata again - # ideally we'd make sure that if go-bindata generated new content, we fail. - # because devs should have run go-bindata and checked in changes already. - # but because git checkout will change the timestamps and mode, it'll generate slight differences, and it's hard to filter those out - # so for now, we just let it slip and assume devs will do a good enough job maintaining the generated data - # - git diff --exit-code - - run: make build-win - - run: make build-darwin - - run: make build-bsd - - persist_to_workspace: - root: . - paths: - - carbon-relay-ng - - carbon-relay-ng.exe - - carbon-relay-ng-darwin - - carbon-relay-ng-linux-amd64 - - carbon-relay-ng-linux-arm64 - - carbon-relay-ng-bsd - - package: - docker: - - image: cimg/ruby:2.5 - steps: - - run: sudo apt-get update - - run: sudo apt-get install rpm - - checkout - - attach_workspace: - at: . - - run: gem install fpm - - run: make packages - - setup_remote_docker - - run: make docker - - run: docker save -o build/carbon-relay-ng.tar grafana/carbon-relay-ng - - run: git describe --tags --always | sed 's/^v//' > build/version.txt - - persist_to_workspace: - root: . - paths: - - build - - deploy: - docker: - - image: cimg/ruby:2.5 - steps: - - setup_remote_docker - - attach_workspace: - at: . - - run: gem install package_cloud - - store_artifacts: - path: build - - store_artifacts: - path: carbon-relay-ng.exe - - store_artifacts: - path: carbon-relay-ng - - deploy: - command: | - if [ "${CIRCLE_BRANCH}" == "master" ]; then - # only versions without a hyphen - e.g. actual releases - go to the main repo. - # in-between-release versions go to testing. - version=$(cat build/version.txt) - repo=raintank/raintank - [[ "$version" == *-* ]] && repo=raintank/testing - # Ubuntu 14.04 (trusty), 16.04 (xenial), debian 8 (jessie), debian 9 (stretch), debian 10 (buster, testing) Centos6 and Centos7. - # (no debian 7 wheezy because that's sysvinit which we don't have packages for) - package_cloud push $repo/ubuntu/trusty build/deb-upstart/carbon-relay-ng-*.deb - package_cloud push $repo/ubuntu/xenial build/deb-systemd/carbon-relay-ng-*.deb - package_cloud push $repo/debian/jessie build/deb-systemd/carbon-relay-ng-*.deb - package_cloud push $repo/debian/stretch build/deb-systemd/carbon-relay-ng-*.deb - package_cloud push $repo/debian/buster build/deb-systemd/carbon-relay-ng-*.deb - package_cloud push $repo/el/6 build/centos-6/carbon-relay-ng-*.el6.*.rpm - package_cloud push $repo/el/7 build/centos-7/carbon-relay-ng-*.el7.*.rpm - - docker load -i build/carbon-relay-ng.tar - docker login -u $DOCKER_USER -p $DOCKER_KEY - - docker push grafana/carbon-relay-ng:$version - # only versions without a hyphen - e.g. actual releases - are tagged as latest. - # in-between-release versions are tagged as master. - tag=latest - [[ "$version" == *-* ]] && tag=master - - docker push grafana/carbon-relay-ng:$tag - fi - - github_binaries: - docker: - - image: cimg/go:1.21.8 - steps: - - checkout - - run: curl -sfL https://goreleaser.com/static/run | bash - # For dry runs use the following and comment the above - # - run: curl -sfL https://goreleaser.com/static/run | bash -s -- --clean --skip-publish --snapshot diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..0ae0ca25 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,120 @@ +name: CI + +on: + push: + tags: + - 'v[0-9]+(\.[0-9]+)*(-.*)*' + pull_request: + +permissions: + contents: read + id-token: write + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: 1.21.8 + - run: make test + + build: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: 1.21.8 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + - name: Install FPM and dependencies + run: | + sudo apt-get update + sudo apt-get install rpm + gem install fpm + - name: Install go-bindata + run: go install github.com/go-bindata/go-bindata/...@latest + - run: make LINUX_PACKAGE_GOARCH=amd64 build-linux + - run: make LINUX_PACKAGE_GOARCH=arm64 build-linux + - run: make build-win + - run: make build-darwin + - run: make build-bsd + - name: Make packages + run: make packages + - name: Build Docker image + run: | + make docker + docker save -o build/carbon-relay-ng.tar grafana/carbon-relay-ng + - name: Store version + run: git describe --tags --always | sed 's/^v//' > build/version.txt + - name: Upload package artifacts + if: github.ref_type == 'tag' + uses: actions/upload-artifact@v4 + with: + include-hidden-files: true + name: package-artifacts + path: build + + # Release, runs on tags only + deploy: + needs: build + runs-on: ubuntu-latest + if: github.ref_type == 'tag' + steps: + - uses: actions/checkout@v3 + - name: Download package artifacts + uses: actions/download-artifact@v4 + with: + name: package-artifacts + path: build + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + - name: Install package_cloud + run: gem install package_cloud + - name: Set PACKAGECLOUD_TOKEN + uses: grafana/shared-workflows/actions/get-vault-secrets@main + with: + repo_secrets: | + PACKAGECLOUD_TOKEN=packagecloud:token + - name: Push packages + run: | + version=$(cat build/version.txt) + repo=raintank/raintank + [[ "$version" == *-* ]] && repo=raintank/testing + package_cloud push $repo/ubuntu/trusty build/deb-upstart/carbon-relay-ng-*.deb + package_cloud push $repo/ubuntu/xenial build/deb-systemd/carbon-relay-ng-*.deb + package_cloud push $repo/debian/jessie build/deb-systemd/carbon-relay-ng-*.deb + package_cloud push $repo/debian/stretch build/deb-systemd/carbon-relay-ng-*.deb + package_cloud push $repo/debian/buster build/deb-systemd/carbon-relay-ng-*.deb + package_cloud push $repo/el/6 build/centos-6/carbon-relay-ng-*.el6.*.rpm + package_cloud push $repo/el/7 build/centos-7/carbon-relay-ng-*.el7.*.rpm + - name: Load Docker image + run: docker load -i build/carbon-relay-ng.tar + - name: Login to DockerHub + uses: grafana/shared-workflows/actions/dockerhub-login@main + - name: Push Docker image + run: | + version=$(cat build/version.txt) + docker push grafana/carbon-relay-ng:$version + # only versions without a hyphen - e.g. actual releases - are tagged as latest. + # in-between-release versions are tagged as master. + tag=latest + [[ "$version" == *-* ]] && tag=master + docker push grafana/carbon-relay-ng:$tag + + github_binaries: + if: github.ref_type == 'tag' + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: 1.21.8 + - name: Run goreleaser + run: curl -sfL https://goreleaser.com/static/run | bash diff --git a/.goreleaser.yml b/.goreleaser.yml index 0da0930d..e48393c9 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,3 +1,4 @@ +version: 2 builds: - id: "carbon-relay-ng" main: ./cmd/carbon-relay-ng @@ -25,4 +26,4 @@ checksum: snapshot: name_template: "{{ .Tag }}-next" changelog: - skip: true + disable: true diff --git a/README.md b/README.md index 8829098c..a76aa5f3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ -[![Circle CI](https://circleci.com/gh/grafana/carbon-relay-ng.svg?style=shield)](https://circleci.com/gh/grafana/carbon-relay-ng) [![Go Report Card](https://goreportcard.com/badge/github.com/grafana/carbon-relay-ng)](https://goreportcard.com/report/github.com/grafana/carbon-relay-ng) [![GoDoc](https://godoc.org/github.com/grafana/carbon-relay-ng?status.svg)](https://godoc.org/github.com/grafana/carbon-relay-ng) +Build + + carbon-relay-ng ===============