|
1 | | -name: CI |
| 1 | +name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | tags: |
6 | | - - "*" |
7 | | - release: |
8 | | - types: |
9 | | - - created |
10 | | - branches: |
11 | | - - "releases/v3.x" |
12 | | - - "chore/fix-ci" |
13 | | - pull_request: |
14 | | - branches: |
15 | | - - "releases/v3.x" |
16 | | - - "chore/fix-ci" |
| 6 | + - "v*" |
17 | 7 | workflow_dispatch: |
18 | 8 | inputs: |
19 | 9 | tag: |
20 | 10 | description: 'Tag to run the workflow for' |
21 | 11 | required: false |
22 | 12 | default: '' |
23 | 13 |
|
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
24 | 21 | jobs: |
25 | 22 | docker: |
| 23 | + name: Build Neutron Image |
26 | 24 | runs-on: |
27 | 25 | group: Neutron-Core |
| 26 | + timeout-minutes: 30 |
28 | 27 | env: |
29 | | - DOCKER_BUILDKIT: 1 |
| 28 | + INPUT_TAG: ${{ github.event.inputs.tag }} |
30 | 29 |
|
31 | 30 | steps: |
32 | 31 | - name: Checkout |
33 | | - uses: actions/checkout@v4 |
| 32 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
34 | 33 | with: |
35 | 34 | fetch-depth: 0 |
36 | 35 | ref: ${{ github.event.inputs.tag || github.ref }} |
37 | 36 |
|
38 | | - - name: Install dependencies |
39 | | - run: sudo apt-get update && sudo apt-get install -y jq curl git |
40 | | - |
41 | | - - name: Install Go |
42 | | - run: | |
43 | | - GO_VERSION=1.23.4 |
44 | | - curl -LO https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz |
45 | | - sudo tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz |
46 | | - echo "export PATH=$PATH:/usr/local/go/bin" >> $HOME/.profile |
47 | | - source $HOME/.profile |
48 | | - shell: bash |
49 | | - |
50 | | - - name: Download Buildx with Hydrobuilder support |
51 | | - run: | |
52 | | - ARCH=amd64 |
53 | | - 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\"))") |
54 | | - mkdir -vp ~/.docker/cli-plugins/ |
55 | | - curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL |
56 | | - chmod a+x ~/.docker/cli-plugins/docker-buildx |
| 37 | + - name: Set up Go |
| 38 | + uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 |
| 39 | + with: |
| 40 | + go-version-file: 'go.mod' |
57 | 41 |
|
58 | | - - name: Get version from git tags or input |
| 42 | + - name: Get version |
59 | 43 | id: get_version |
60 | 44 | run: | |
61 | | - if [ -n "${{ github.event.inputs.tag }}" ]; then |
62 | | - VERSION=${{ github.event.inputs.tag }} |
| 45 | + if [ -n "$INPUT_TAG" ]; then |
| 46 | + VERSION="$INPUT_TAG" |
63 | 47 | else |
64 | 48 | VERSION=$(git describe --tags --abbrev=0) |
65 | 49 | fi |
66 | | - echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 50 | + if [ -z "$VERSION" ]; then |
| 51 | + echo "::error::Failed to determine version" |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | + echo "VERSION=$VERSION" >> "$GITHUB_ENV" |
67 | 55 |
|
68 | 56 | - name: Log in to Docker Hub |
69 | | - run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin |
70 | | - |
71 | | - - name: Set up Docker Buildx |
72 | | - id: buildx |
73 | | - uses: docker/setup-buildx-action@v3 |
| 57 | + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 |
74 | 58 | with: |
75 | | - version: "lab:latest" |
76 | | - driver: cloud |
77 | | - endpoint: "neutronorg/neutron" |
78 | | - install: true |
| 59 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 60 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
79 | 61 |
|
80 | | - - name: Build and push Docker image |
| 62 | + - name: Build Docker image |
| 63 | + run: make build-static-linux-amd64 |
| 64 | + |
| 65 | + - name: Push Docker image |
81 | 66 | env: |
82 | 67 | VERSION: ${{ env.VERSION }} |
83 | | - BUILDER: ${{ steps.buildx.outputs.name }} |
84 | 68 | run: | |
85 | | - docker buildx use $BUILDER |
86 | | - make build-static-linux-amd64 |
87 | | - docker tag neutron-amd64:latest neutronorg/neutron:${{ env.VERSION }} |
88 | | - docker push neutronorg/neutron:${{ env.VERSION }} |
89 | | -
|
90 | | - - name: Cleanup temporary container |
91 | | - run: docker rm -f neutronbinary || true |
| 69 | + docker tag neutron-amd64:latest "neutronorg/neutron:${VERSION}" |
| 70 | + docker push "neutronorg/neutron:${VERSION}" |
0 commit comments