Merge pull request #89 from hzieba/arm64-docker #9
Workflow file for this run
This file contains hidden or 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: | |
tags: | |
- 'v*' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
- name: Install dependencies | |
run: | | |
go mod download | |
- name: Run Unit tests | |
run: | | |
go test -race ./... | |
- name: Build | |
run: | | |
go build -ldflags "-X main.Version=${{ github.ref }}" ./... | |
env: | |
CGO_ENABLED: 0 | |
- name: Strip | |
run: /usr/bin/strip cortex-tenant | |
- name: Create DEB package root | |
run: | | |
mkdir -p .debpkg/usr/sbin | |
mkdir -p .debpkg/etc/systemd/system | |
mkdir -p .debpkg/etc/default | |
mkdir -p .debpkg/DEBIAN | |
cp cortex-tenant .debpkg/usr/sbin | |
cp deploy/cortex-tenant.deb.service .debpkg/etc/systemd/system/cortex-tenant.service | |
cp deploy/cortex-tenant.env .debpkg/etc/default/cortex-tenant | |
cp deploy/after_install.sh .debpkg/DEBIAN/postinst | |
chmod +x .debpkg/DEBIAN/postinst | |
- name: Create RPM package root | |
run: | | |
mkdir -p .rpmpkg/usr/sbin | |
mkdir -p .rpmpkg/etc/systemd/system | |
mkdir -p .rpmpkg/etc/sysconfig | |
cp cortex-tenant .rpmpkg/usr/sbin | |
cp deploy/cortex-tenant.rpm.service .rpmpkg/etc/systemd/system/cortex-tenant.service | |
cp deploy/cortex-tenant.env .rpmpkg/etc/sysconfig/cortex-tenant | |
- uses: jiro4989/build-deb-action@v3 | |
with: | |
package: cortex-tenant | |
package_root: .debpkg | |
maintainer: "Igor Novgorodov <[email protected]>" | |
version: ${{ github.ref }} | |
arch: 'amd64' | |
desc: "Cortex-Tenant Service" | |
homepage: "https://github.com/blind-oracle/cortex-tenant" | |
- uses: jiro4989/build-rpm-action@v2 | |
with: | |
package: cortex-tenant | |
package_root: .rpmpkg | |
maintainer: "Igor Novgorodov <[email protected]>" | |
version: ${{ github.ref }} | |
arch: 'x86_64' | |
summary: "Cortex-Tenant Service" | |
- uses: ncipollo/release-action@v1 | |
with: | |
makeLatest: true | |
generateReleaseNotes: true | |
artifacts: "cortex-tenant,*.deb,*.rpm" | |
publish-docker-image: | |
runs-on: ubuntu-24.04 | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
id: push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true |