Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move releasing binaries to GH Actions #945

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
release-binaries:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.23'

- name: Build binaries
run: |
make build-all-binaries
ls -la
./package-github-binaries.sh
ls -la dist/

- name: Add binaries to release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
allowUpdates: true
24 changes: 17 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ jobs:
make test
- name: Upload coverage to Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t $CODECOV_TOKEN -f coverage.txt
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: ./coverage.txt
token: ${{ secrets.CODECOV_TOKEN }} # required
verbose: true

- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
Expand Down Expand Up @@ -101,3 +100,14 @@ jobs:

- name: Generate mixin
run: make mixin

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Test Docker Build
uses: docker/build-push-action@v6
with:
push: false
tags: user/app:tst
file: docker/Dockerfile
build-args: "GOARCH=amd64"
16 changes: 4 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ docker-all: docker-env-up docker-test docker-env-down

.PHONY: docker-env-up
docker-env-up:
$(DOCKER_COMPOSE) -f contrib/docker-compose-for-tests.yml up -d
$(DOCKER_COMPOSE) -f docker-compose.yml up -d


.PHONY: docker-env-down
docker-env-down:
$(DOCKER_COMPOSE) -f contrib/docker-compose-for-tests.yml down
$(DOCKER_COMPOSE) -f docker-compose.yml down


.PHONY: docker-test
docker-test:
$(DOCKER_COMPOSE) -f contrib/docker-compose-for-tests.yml up -d
$(DOCKER_COMPOSE) -f contrib/docker-compose-for-tests.yml run --rm tests bash -c 'make test'
$(DOCKER_COMPOSE) -f docker-compose.yml up -d
$(DOCKER_COMPOSE) -f docker-compose.yml run --rm tests bash -c 'make test'



Expand Down Expand Up @@ -68,14 +68,6 @@ mixin:
$(MAKE) all && \
cd ../../

.PHONY: upload-coverage
upload-coverage:
go install github.com/mattn/[email protected]
which goveralls
echo $PATH
/home/runner/go/bin/goveralls -coverprofile=coverage.txt -service=drone.io



BUILD_DT:=$(shell date +%F-%T)
GO_LDFLAGS:="-s -w -extldflags \"-static\" -X main.BuildVersion=${DRONE_TAG} -X main.BuildCommitSha=${DRONE_COMMIT_SHA} -X main.BuildDate=$(BUILD_DT)"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ With this count, we can take following actions such as Create alerts or dashboar

The tests require a variety of real Redis instances to not only verify correctness of the exporter but also
compatibility with older versions of Redis and with Redis-like systems like KeyDB or Tile38.\
The [contrib/docker-compose-for-tests.yml](./contrib/docker-compose-for-tests.yml) file has service definitions for
The [docker-compose.yml](docker-compose.yml) file has service definitions for
everything that's needed.\
You can bring up the Redis test instances first by running `make docker-env-up` and then, every time you want to run the tests, you can run `make docker-test`. This will mount the current directory (with the .go source files) into a docker container and kick off the tests.\
Once you're done testing you can bring down the stack by running `make docker-env-down`.\
Expand Down
4 changes: 3 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ ARG SHA1="[no-sha]"
ARG TAG="[no-tag]"
ARG GOARCH

RUN printf "nameserver 1.1.1.1\nnameserver 8.8.8.8"> /etc/resolv.conf \ && apk --no-cache add ca-certificates git
#RUN printf "nameserver 1.1.1.1\nnameserver 8.8.8.8"> /etc/resolv.conf \ && apk --no-cache add ca-certificates git

RUN apk --no-cache add ca-certificates git
RUN BUILD_DATE=$(date +%F-%T) CGO_ENABLED=0 GOOS=linux GOARCH=$GOARCH go build -o /redis_exporter \
-ldflags "-s -w -extldflags \"-static\" -X main.BuildVersion=$TAG -X main.BuildCommitSha=$SHA1 -X main.BuildDate=$BUILD_DATE" .

Expand Down
26 changes: 26 additions & 0 deletions package-github-binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -u -e -o pipefail

mkdir -p dist

for build in $(ls .build); do
echo "Creating archive for ${build}"

cp LICENSE README.md ".build/${build}/"

if [[ "${build}" =~ windows-.*$ ]] ; then

# Make sure to clear out zip files to prevent zip from appending to the archive.
rm "dist/${build}.zip" || true
cd ".build/" && zip -r --quiet -9 "../dist/${build}.zip" "${build}" && cd ../
else
tar -C ".build/" -czf "dist/${build}.tar.gz" "${build}"
fi
done

cd dist
sha256sum *.gz *.zip > sha256sums.txt
ls -la
cd ..

Loading