chore: migrate to github actions #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
tags: | |
- 'v[0-9]+(\.[0-9]+)*(-.*)*' | |
pull_request: | |
branches: | |
- '**' | |
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 | |
- 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: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-artifacts | |
path: | | |
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: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- 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: Download build artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-artifacts | |
- 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 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: package-artifacts | |
path: build | |
deploy: | |
needs: package | |
runs-on: ubuntu-latest | |
# TODO: testing in PR | |
# if: github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download package artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: package-artifacts | |
- 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 | |
repo=raintank/testing # TODO | |
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: Push Docker image | |
run: | | |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_KEY }} | |
version=$(cat build/version.txt) | |
docker push grafana/carbon-relay-ng:$version | |
tag=latest | |
[[ "$version" == *-* ]] && tag=master | |
docker push grafana/carbon-relay-ng:$tag | |
github_binaries: | |
needs: deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Run goreleaser | |
# TODO: currently dry running | |
run: curl -sfL https://goreleaser.com/static/run | bash -s -- --clean --skip-publish --snapshot |