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

Publish to ghcr.io #2

Closed
wants to merge 1 commit into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches-ignore:
- 'release-*'
tags-ignore:
- '*.*'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1

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

- name: Run checks
run: |
make ci
134 changes: 58 additions & 76 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,76 @@
name: Build and Publish artifacts
name: Release

on:
workflow_dispatch:
push:
tags:
- '*.*.*'
- "*.*"
- "*.*.*"

jobs:
build:
name: Build and upload artifacts
runs-on: ubuntu-latest
env:
VERSION: ${{ github.ref_name }}
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ^1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Promu - Crossbuild
run: make crossbuild

- name: Promu - Prepare packages
run: make crossbuild-tarballs
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

- name: Create deb package
uses: burningalchemist/action-gh-nfpm@v1
with:
packager: deb
config: packaging/conf/nfpm.yaml
target: .tarballs/
- name: Create rpm package
uses: burningalchemist/action-gh-nfpm@v1
with:
packager: rpm
config: packaging/conf/nfpm.yaml
target: .tarballs/
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

- name: Calculate checksums
run: make crossbuild-checksum
jobs:
label-detector:
name: Runner Label
runs-on: label-detector
outputs:
runs-on: ${{ steps.detector.outputs.label }}
steps:
- name: Detect Label
id: detector
run: |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs
echo "label=$(curl -fsSL https://this-is-nats.appscode.ninja/runs-on/${{ github.repository_owner }}?visibility=${{ github.repository_visibility }})" >> $GITHUB_OUTPUT

- name: Upload artifacts
uses: softprops/action-gh-release@v2
with:
files: |
.tarballs/*
docker:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: build
build:
name: Build
needs: label-detector
runs-on: "${{ needs.label-detector.outputs.runs-on }}"
steps:
- name: Check out the repo
uses: actions/checkout@v4
- uses: actions/checkout@v1

- name: Get Go version from the '.promu.yml' config
id: promu-go-version
run: printf "version=%s" "$(yq '.go.version' .promu.yml)" >> $GITHUB_OUTPUT

- name: Print version info
id: semver
run: |
cd rabbitmq-init
make version

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
id: qemu
uses: docker/setup-qemu-action@v1

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

- name: Log in to Docker Hub
uses: docker/login-action@v3
- name: Log in to the GitHub Container registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: burningalchemist/sql_exporter
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Run checks
run: |
make promu
make check_license style staticcheck unused build test-short
make ci

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.multi-arch
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
provenance: false
build-args: |
GOVERSION=${{ steps.promu-go-version.outputs.version }}
- name: Build
env:
DOCKER_REPO: kubedb
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
USERNAME: 1gtm
run: |
export PATH=$(go env GOPATH)/bin:$PATH
export DOCKER_IMAGE_TAG=${GITHUB_REF#"refs/tags/"}
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
promu crossbuild
make docker
make docker-publish
make docker-manifest
make release
40 changes: 37 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
/.project
/.settings
/.vscode
/sql_exporter
/sql_exporter.yml
.idea/*


# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

/bin
/.go

/.idea
/.markdownlint.json
/.vscode
/apiserver.local.config
/test/e2e/apiserver.local.config
/coverage.txt
/dist
/hack/config/.env
/test/e2e/junit.xml
/test/e2e/report.xml
Loading
Loading