Merge pull request #104 from grafana/install-git #43
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: Release | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- 'v*.*.*' | |
jobs: | |
docker: | |
name: Build and publish Docker image | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_REPOSITORY: ${{ github.repository }} | |
VERSION: ${{ github.ref_name }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Build image | |
run: docker build -t "$IMAGE_REPOSITORY" . | |
- name: Build k6 binary | |
run: | | |
docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/xk6" \ | |
"$IMAGE_REPOSITORY" build master \ | |
--with github.com/grafana/xk6-sql \ | |
--with github.com/grafana/xk6-output-influxdb | |
- name: Check k6 binary | |
run: | | |
./k6 version | |
./k6 version | grep -qz 'xk6-output-influxdb.*xk6-sql' | |
- name: Log into ghcr.io | |
if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }} | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Publish master image to ghcr.io | |
if: ${{ github.ref == 'refs/heads/master' }} | |
run: | | |
echo "Publish as ghcr.io/${IMAGE_REPOSITORY}:master" | |
docker tag "$IMAGE_REPOSITORY" "ghcr.io/${IMAGE_REPOSITORY}:master" | |
docker push "ghcr.io/${IMAGE_REPOSITORY}:master" | |
- name: Publish tagged version image to ghcr.io | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
run: | | |
VERSION="${VERSION#v}" | |
echo "Publish as ghcr.io/${IMAGE_REPOSITORY}:${VERSION}" | |
docker tag "$IMAGE_REPOSITORY" "ghcr.io/${IMAGE_REPOSITORY}:${VERSION}" | |
docker push "ghcr.io/${IMAGE_REPOSITORY}:${VERSION}" | |
# We also want to tag the latest stable version as latest | |
if [[ ! "$VERSION" =~ (RC|rc) ]]; then | |
echo "Publish as ghcr.io/${IMAGE_REPOSITORY}:latest" | |
docker tag "$IMAGE_REPOSITORY" "ghcr.io/${IMAGE_REPOSITORY}:latest" | |
docker push "ghcr.io/${IMAGE_REPOSITORY}:latest" | |
fi | |
- name: Log into Docker Hub | |
if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }} | |
run: | | |
echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin | |
- name: Publish master image to Docker Hub | |
if: ${{ github.ref == 'refs/heads/master' }} | |
run: | | |
echo "Publish as ${IMAGE_REPOSITORY}:master" | |
docker tag "$IMAGE_REPOSITORY" "${IMAGE_REPOSITORY}:master" | |
docker push "${IMAGE_REPOSITORY}:master" | |
- name: Publish tagged version image to Docker Hub | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
run: | | |
VERSION="${VERSION#v}" | |
echo "Publish as ${IMAGE_REPOSITORY}:${VERSION}" | |
docker tag "$IMAGE_REPOSITORY" "${IMAGE_REPOSITORY}:${VERSION}" | |
docker push "${IMAGE_REPOSITORY}:${VERSION}" | |
# We also want to tag the latest stable version as latest | |
if [[ ! "$VERSION" =~ (RC|rc) ]]; then | |
echo "Publish as ${IMAGE_REPOSITORY}:latest" | |
docker tag "$IMAGE_REPOSITORY" "${IMAGE_REPOSITORY}:latest" | |
docker push "${IMAGE_REPOSITORY}:latest" | |
fi |