fixup! Fix Docker builds after upgrade to 1.23 (#153) (#154) #135
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 standalone binaries and Docker images" | |
on: | |
push: | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+" | |
- "v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z0-9]+" | |
jobs: | |
release: | |
name: Build and release all | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Set up Go 1.23 | |
if: success() | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.23 | |
- name: Checkout code | |
if: success() | |
uses: actions/checkout@v3 | |
# Install the cosign tool except on PR | |
# https://github.com/sigstore/cosign-installer | |
- name: Install cosign | |
if: github.event_name != 'pull_request' | |
uses: sigstore/[email protected] | |
with: | |
cosign-release: 'v1.13.1' | |
- name: "Get tag data" | |
if: success() | |
id: git_tags | |
run: | | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
git fetch --prune --unshallow | |
- name: Download module dependencies | |
if: success() | |
env: | |
GOPROXY: "https://proxy.golang.org" | |
run: | | |
go clean -modcache | |
go mod download | |
- name: Install libsystemd-dev | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libsystemd-dev gcc-aarch64-linux-gnu | |
- name: Build binaries for Linux | |
if: success() | |
id: build_binaries | |
run: | | |
make build-linux-amd64 | |
CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc make build-linux-arm64 | |
- name: Check if prerelease | |
id: check_prerelease | |
run: | | |
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+-[a-zA-Z0-9]+$ ]]; then | |
echo "prerelease=true" >> $GITHUB_OUTPUT | |
else | |
echo "prerelease=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Get latest release (or prerelease) tag | |
id: git_last_tag | |
run: | | |
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+-[a-zA-Z0-9]+$ ]]; then | |
echo '::set-output name=previous_tag::$(git tag --sort=version:refname | grep -v "$(git describe --tags)" | grep -E "v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z0-9]+$"| tail -n1)' | |
else | |
echo '::set-output name=previous_tag::$(git tag --sort=version:refname | grep -v "$(git describe --tags)" | grep -E "v[0-9]+.[0-9]+.[0-9]+$"| tail -n1)' | |
fi | |
- name: Create Release Changelog | |
id: git_release_changelog | |
if: success() | |
run: | | |
export RELEASE_BODY=$(git log --no-merges ${{ steps.git_last_tag.outputs.previous_tag }}..${{ github.ref }} --format='* [%h] %s (%an)') | |
RELEASE_BODY="${RELEASE_BODY//'%'/'%25'}" | |
RELEASE_BODY="${RELEASE_BODY//$'\n'/'%0A'}" | |
RELEASE_BODY="${RELEASE_BODY//$'\r'/'%0D'}" | |
echo "::set-output name=release_body::$RELEASE_BODY" | |
- name: Create Release | |
if: success() | |
id: create_release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ github.ref }} | |
body: ${{ steps.git_release_changelog.outputs.release_body }} | |
draft: false | |
prerelease: ${{ steps.check_prerelease.outputs.prerelease == 'true' && 'true' || 'false' }} | |
- name: Upload Release Asset Linux amd64 (Flow) | |
if: success() | |
id: upload-release-flow-asset-linux-amd64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./metrikad-flow-linux-amd64 | |
asset_name: metrikad-flow-linux-amd64 | |
asset_content_type: application/octet-stream | |
- name: Upload Release Asset Linux amd64 checksum (Flow) | |
if: success() | |
id: upload-release-flow-asset-linux-amd64-checksum | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./metrikad-flow-linux-amd64.sha256 | |
asset_name: metrikad-flow-linux-amd64.sha256 | |
asset_content_type: text/plain | |
- name: Upload Release Asset Linux arm64 (Flow) | |
if: success() | |
id: upload-release-flow-asset-linux-arm64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./metrikad-flow-linux-arm64 | |
asset_name: metrikad-flow-linux-arm64 | |
asset_content_type: application/octet-stream | |
- name: Upload Release Asset Linux arm64 checksum (Flow) | |
if: success() | |
id: upload-release-flow-asset-linux-arm64-checksum | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./metrikad-flow-linux-arm64.sha256 | |
asset_name: metrikad-flow-linux-arm64.sha256 | |
asset_content_type: text/plain | |
- name: Upload Release Asset Linux amd64 (Solana) | |
if: success() | |
id: upload-release-solana-asset-linux-amd64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./metrikad-solana-linux-amd64 | |
asset_name: metrikad-solana-linux-amd64 | |
asset_content_type: application/octet-stream | |
- name: Upload Release Asset Linux amd64 checksum (Solana) | |
if: success() | |
id: upload-release-solana-asset-linux-amd64-checksum | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./metrikad-solana-linux-amd64.sha256 | |
asset_name: metrikad-solana-linux-amd64.sha256 | |
asset_content_type: text/plain | |
- name: Upload Release Asset Linux arm64 (Solana) | |
if: success() | |
id: upload-release-solana-asset-linux-arm64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./metrikad-solana-linux-arm64 | |
asset_name: metrikad-solana-linux-arm64 | |
asset_content_type: application/octet-stream | |
- name: Upload Release Asset Linux arm64 checksum (Solana) | |
if: success() | |
id: upload-release-solana-asset-linux-arm64-checksum | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./metrikad-solana-linux-arm64.sha256 | |
asset_name: metrikad-solana-linux-arm64.sha256 | |
asset_content_type: text/plain | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Sanitize repo slug | |
uses: actions/github-script@v6 | |
id: repo_slug | |
with: | |
result-encoding: string | |
script: return 'ghcr.io/${{ github.repository }}'.toLowerCase() | |
- name: Extract metadata (tags, labels) for Docker (Flow) | |
id: meta_flow | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ steps.repo_slug.outputs.result }} | |
flavor: | | |
latest=false | |
tags: | | |
type=semver,pattern={{raw}} | |
type=raw,value=latest-flow | |
- name: Extract metadata (tags, labels) for Docker (Solana) | |
id: meta_solana | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ steps.repo_slug.outputs.result }} | |
flavor: | | |
latest=false | |
tags: | | |
type=semver,pattern={{raw}} | |
type=raw,value=latest-solana | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
buildkitd-flags: --debug | |
- name: Build and push Docker images (Flow) | |
id: build-and-push-flow | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
file: docker/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
build-args: | | |
MA_PROTOCOL=flow | |
MA_VERSION=${{ steps.meta_flow.outputs.version }} | |
tags: ${{ steps.meta_flow.outputs.tags }} | |
labels: ${{ steps.meta_flow.outputs.labels }} | |
- name: Build and push Docker images (Solana) | |
id: build-and-push-solana | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
file: docker/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
build-args: | | |
MA_PROTOCOL=solana | |
MA_VERSION=${{ steps.meta_solana.outputs.version }} | |
tags: ${{ steps.meta_solana.outputs.tags }} | |
labels: ${{ steps.meta_solana.outputs.labels }} | |
- name: Sign the published Docker images (Flow) | |
if: github.event_name != 'pull_request' | |
run: | | |
cosign sign --key env://COSIGN_PRIVATE_KEY \ | |
-a "repo=${{ github.repository }}" \ | |
-a "ref=${{ github.sha }}" \ | |
${{ steps.repo_slug.outputs.result }}@${{ steps.build-and-push-flow.outputs.digest }} | |
env: | |
COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}} | |
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}} | |
- name: Sign the published Docker images (Solana) | |
if: github.event_name != 'pull_request' | |
run: | | |
cosign sign --key env://COSIGN_PRIVATE_KEY \ | |
-a "repo=${{ github.repository }}" \ | |
-a "ref=${{ github.sha }}" \ | |
${{ steps.repo_slug.outputs.result }}@${{ steps.build-and-push-solana.outputs.digest }} | |
env: | |
COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}} | |
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}} | |
- name: Slack Notification Failure | |
if: failure() | |
id: status | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_MESSAGE: "${{ github.event.head_commit.message }}" | |
SLACK_TITLE: GitHub Release Metrika Agent | |
SLACK_WEBHOOK: ${{ secrets.METRIKA_SLACK_NON_PROD_WEBHOOK }} | |
SLACK_ICON: https://app.metrika.co/logo192.png?size=48 | |
SLACK_CHANNEL: "cicd-node-agent" | |
SLACK_USERNAME: "github-ci-metrika-agent" | |
SLACK_COLOR: ${{ job.status }} | |
SLACK_FOOTER: "Sent by GitHub CI from Metrika Agent repo" | |
- name: Slack Notification Success | |
if: success() | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_MESSAGE: "${{ github.event.head_commit.message }}" | |
SLACK_TITLE: GitHub Release Metrika Agent | |
SLACK_WEBHOOK: ${{ secrets.METRIKA_SLACK_NON_PROD_WEBHOOK }} | |
SLACK_ICON: https://app.metrika.co/logo192.png?size=48 | |
SLACK_CHANNEL: "cicd-node-agent" | |
SLACK_USERNAME: "github-release-metrika-agent" | |
SLACK_COLOR: ${{ job.status }} | |
SLACK_FOOTER: "Sent by GitHub Release Job from Metrika Agent repo" |