Skip to content
Merged
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
89 changes: 34 additions & 55 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,91 +1,70 @@
name: CI
name: Release

on:
push:
tags:
- "*"
release:
types:
- created
branches:
- "releases/v3.x"
- "chore/fix-ci"
pull_request:
branches:
- "releases/v3.x"
- "chore/fix-ci"
- "v*"
workflow_dispatch:
inputs:
tag:
description: 'Tag to run the workflow for'
required: false
default: ''

permissions:
contents: read

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

jobs:
docker:
name: Build Neutron Image
runs-on:
group: Neutron-Core
timeout-minutes: 30
env:
DOCKER_BUILDKIT: 1
INPUT_TAG: ${{ github.event.inputs.tag }}

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
ref: ${{ github.event.inputs.tag || github.ref }}

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y jq curl git

- name: Install Go
run: |
GO_VERSION=1.23.4
curl -LO https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
echo "export PATH=$PATH:/usr/local/go/bin" >> $HOME/.profile
source $HOME/.profile
shell: bash

- name: Download Buildx with Hydrobuilder support
run: |
ARCH=amd64
BUILDX_URL=$(curl -s https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json | jq -r ".latest.assets[] | select(endswith(\"linux-$ARCH\"))")
mkdir -vp ~/.docker/cli-plugins/
curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL
chmod a+x ~/.docker/cli-plugins/docker-buildx
- name: Set up Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: 'go.mod'

- name: Get version from git tags or input
- name: Get version
id: get_version
run: |
if [ -n "${{ github.event.inputs.tag }}" ]; then
VERSION=${{ github.event.inputs.tag }}
if [ -n "$INPUT_TAG" ]; then
VERSION="$INPUT_TAG"
else
VERSION=$(git describe --tags --abbrev=0)
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
if [ -z "$VERSION" ]; then
echo "::error::Failed to determine version"
exit 1
fi
echo "VERSION=$VERSION" >> "$GITHUB_ENV"

- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
version: "lab:latest"
driver: cloud
endpoint: "neutronorg/neutron"
install: true
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
- name: Build Docker image
run: make build-static-linux-amd64

- name: Push Docker image
env:
VERSION: ${{ env.VERSION }}
BUILDER: ${{ steps.buildx.outputs.name }}
run: |
docker buildx use $BUILDER
make build-static-linux-amd64
docker tag neutron-amd64:latest neutronorg/neutron:${{ env.VERSION }}
docker push neutronorg/neutron:${{ env.VERSION }}

- name: Cleanup temporary container
run: docker rm -f neutronbinary || true
docker tag neutron-amd64:latest "neutronorg/neutron:${VERSION}"
docker push "neutronorg/neutron:${VERSION}"
Loading