Neard binary image - custom build #131
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: Neard binary image - custom build | |
on: | |
# Run when a new release or rc is created | |
push: | |
branches: | |
- statelessnet_master | |
- statelessnet_latest | |
workflow_dispatch: | |
inputs: | |
release: | |
default: 'neard-release' | |
description: "Nearcore release type to do" | |
type: string | |
required: true | |
branch: | |
default: 'master' | |
description: "Nearcore branch to build and publish" | |
type: string | |
required: true | |
jobs: | |
binary-release: | |
name: "Build and publish neard binary" | |
runs-on: "ubuntu-20.04-16core" | |
environment: deploy | |
permissions: | |
id-token: write # required to use OIDC authentication | |
steps: | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::754641474505:role/GitHubActionsRunner | |
aws-region: us-west-1 | |
- name: Checkout ${{ github.event.inputs.branch }} branch | |
if: ${{ github.event_name == 'workflow_dispatch'}} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.branch }} | |
- name: Checkout nearcore repository | |
if: ${{ github.event_name != 'workflow_dispatch'}} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set vars for workflow | |
if: ${{ github.event_name == 'push'}} | |
run: | | |
echo "RELEASE_NAME=statelessnet-release" >> $GITHUB_ENV | |
- name: Set vars for workflow | |
if: ${{ github.event_name == 'workflow_dispatch'}} | |
run: | | |
echo "RELEASE_NAME=${{ github.event.inputs.release }}" >> $GITHUB_ENV | |
- name: Neard binary build and upload to S3 | |
run: ./scripts/binary_release.sh ${{ env.RELEASE_NAME }} | |
- name: Update latest version metadata in S3 | |
run: | | |
echo $(git rev-parse HEAD) > latest | |
BRANCH=$(git branch --show-current) | |
# in case of Release triggered run, branch is empty | |
if [ -z "$BRANCH" ]; then | |
BRANCH=$(git branch -r --contains=${{ github.ref_name }} | head -n1 | cut -c3- | cut -d / -f 2) | |
fi | |
aws s3 cp --acl public-read latest s3://build.nearprotocol.com/nearcore/$(uname)/${BRANCH}/${{ env.RELEASE_NAME }}/latest | |
docker-release: | |
name: "Build and publish nearcore Docker image" | |
runs-on: "ubuntu-20.04-16core" | |
environment: deploy | |
steps: | |
- name: Checkout ${{ github.event.inputs.branch }} branch | |
if: ${{ github.event_name == 'workflow_dispatch'}} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.branch }} | |
- name: Checkout nearcore repository | |
if: ${{ github.event_name != 'workflow_dispatch'}} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKER_PAT_TOKEN }} | |
- name: Build and push Docker image to Dockerhub | |
run: | | |
COMMIT=$(git rev-parse HEAD) | |
BRANCH=$(git branch --show-current) | |
# in case of Release triggered run, branch is empty | |
if [ -z "$BRANCH" ]; then | |
BRANCH=$(git branch -r --contains=${{ github.ref_name }} | head -n1 | cut -c3- | cut -d / -f 2) | |
fi | |
make docker-nearcore | |
docker tag nearcore nearprotocol/nearcore:${BRANCH}-${COMMIT} | |
docker tag nearcore nearprotocol/nearcore:${BRANCH} | |
docker push nearprotocol/nearcore:${BRANCH}-${COMMIT} | |
docker push nearprotocol/nearcore:${BRANCH} | |
if [[ ${BRANCH} == "master" ]]; | |
then | |
docker tag nearcore nearprotocol/nearcore:latest | |
docker push nearprotocol/nearcore:latest | |
fi |