Skip to content

Commit

Permalink
use gh actions for testing, releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
circa10a committed Dec 11, 2022
1 parent a2a7333 commit 3d8315d
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 60 deletions.
57 changes: 0 additions & 57 deletions .drone.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: build
on: [
push,
pull_request
]
jobs:
test:
runs-on: ubuntu-latest
steps:
- id: vars
run: |
echo ::set-output name=go_version::$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g')
echo "Using Go version ${{ steps.vars.outputs.go_version }}"
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ steps.vars.outputs.go_version }}
- name: Checkout code
uses: actions/checkout@v2
- name: build
run: |
make build
make test
make vet
make lint
30 changes: 30 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: GoReleaser
on:
workflow_run:
workflows: ["Bump Git/Docker Version"]
branches: [master]
types:
- completed
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
run: git fetch --prune --unshallow
- id: vars
run: |
echo ::set-output name=go_version::$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g')
echo "Using Go version ${{ steps.vars.outputs.go_version }}"
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ steps.vars.outputs.go_version }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52 changes: 52 additions & 0 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Bump Git/Docker Version
on:
push:
branches:
- master
env:
PLATFORMS: linux/arm/v7,linux/amd64,linux/arm64, windows/amd64, darwin/amd64

jobs:
semver:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tagging.outputs.new_tag }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Bump version and push tag
uses: anothrNick/github-tag-action@1.39.0
id: tagging
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
RELEASE_BRANCHES: master
DEFAULT_BUMP: minor
docker:
runs-on: ubuntu-latest
needs: semver
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.docker_username }}
password: ${{ secrets.docker_password }}
- name: Build and push latest
id: docker_build_latest
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ github.repository }}:latest
platforms: ${{ env.PLATFORMS }}
- name: Build and push versioned
id: docker_build_versioned
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ github.repository }}:${{ needs.semver.outputs.tag }}
platforms: ${{ env.PLATFORMS }}
27 changes: 27 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
before:
hooks:
- go mod tidy
builds:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.Version={{.Version}} -X main.Commit={{.Commit}}'
goos:
- linux
goarch:
- amd64
binary: '{{ .ProjectName }}_v{{ .Version }}'
archives:
- format: binary
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
changelog:
skip: false
sort: asc
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ To deploy directly onto digitalocean, click the button below.
#### Docker

```bash
docker pull metalmatze/digitalocean_exporter:0.6.1
docker run --rm -p 9212:9212 -e DIGITALOCEAN_TOKEN=XXX metalmatze/digitalocean_exporter:0.6.1
docker run --rm -p 9212:9212 -e DIGITALOCEAN_TOKEN=XXX metalmatze/digitalocean_exporter
```

Example `docker-compose.yml` with Transmission also running in docker.

```yaml
digitalocean_exporter:
image: metalmatze/digitalocean_exporter:0.6.1
image: metalmatze/digitalocean_exporter
environment:
- '-do.token=XXX'
restart: always
Expand Down

0 comments on commit 3d8315d

Please sign in to comment.