Skip to content

Commit

Permalink
ci: add build metadata for cosmovisor
Browse files Browse the repository at this point in the history
  • Loading branch information
ivivanov authored and ivivanov committed Feb 29, 2024
1 parent 1db3387 commit 1c54fa4
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 142 deletions.
135 changes: 85 additions & 50 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,37 @@ env:
# make sure to update build-binary container tag as well
IMAGE_TAG: "1.21.6"
DOCKERFILE: ".github/images/builder.Dockerfile"
CHECKSUM_FILE: "sha256sum.txt"
METADATA_FILE: "${{ github.ref_name }}_binaries.json"

jobs:
# Checks if builder image exists in docker registry
builder-exists:
name: Builder exists
runs-on: ubuntu-latest
container: amazon/aws-cli
outputs:
# 'failure' - when no image with such tag exists
# 'success' - image exists
status: ${{ steps.check.outcome }}

steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Run check exist image
id: check
continue-on-error: true
run: |
aws ecr-public describe-images \
--registry-id $AWS_REGISTRY_ID \
--repository-name $ERC_REPOSITORY \
--region $AWS_REGION \
--image-ids=imageTag=$IMAGE_TAG
name: Builder exists
runs-on: ubuntu-latest
container: amazon/aws-cli
outputs:
# 'failure' - when no image with such tag exists
# 'success' - image exists
status: ${{ steps.check.outcome }}

steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Run check exist image
id: check
continue-on-error: true
run: |
aws ecr-public describe-images \
--registry-id $AWS_REGISTRY_ID \
--repository-name $ERC_REPOSITORY \
--region $AWS_REGION \
--image-ids=imageTag=$IMAGE_TAG
# Builds and pushed builder image if it does not exist
builder-create:
Expand Down Expand Up @@ -91,40 +93,71 @@ jobs:
image: "public.ecr.aws/nolus/builder:1.21.6"

steps:
- uses: actions/checkout@v3

# This is to fix GIT not liking owner of the checkout dir
# Happens when executing not into the default container
- name: Set ownership
run: |
chown -R $(id -u):$(id -g) $PWD
- name: Run build binary
run: |
make build
echo "Ensuring binary is statically linked ..."
file target/release/nolusd | grep "statically linked"
- name: Prepare binary tar
run: |
tar -C target/release/ -czvf $ARTIFACT_BIN .
- name: Archive binary
uses: actions/upload-artifact@v3
with:
name: nolusd-${{ env.VERSION_TAG }}
path: ${{ env.ARTIFACT_BIN }}
- uses: actions/checkout@v3

# This is to fix GIT not liking owner of the checkout dir
# Happens when executing not into the default container
- name: Set ownership
run: |
chown -R $(id -u):$(id -g) $PWD
- name: Run build binary
run: |
make build
echo "Ensuring binary is statically linked ..."
file target/release/nolusd | grep "statically linked"
- name: Prepare binary tar
run: |
tar -C target/release/ -czvf $ARTIFACT_BIN .
- name: Upload binary tar
uses: actions/upload-artifact@v4
with:
name: nolusd-tar-${{ env.VERSION_TAG }}
path: ${{ env.ARTIFACT_BIN }}

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: nolusd-${{ env.VERSION_TAG }}
path: target/release/nolusd

# Add metadata for cosmovisor
add-meta:
name: Add metadata
needs: build-binary
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4

- name: Get binary checksum
run: |
CHECKSUM=$(shasum -a 256 nolusd-"${VERSION_TAG}"/nolusd)
echo "$CHECKSUM" > $CHECKSUM_FILE
HASH=$(echo "$CHECKSUM" | cut -d' ' -f1)
JSON="{\"binaries\": {\"linux/amd64\": \"https://github.com/nolus-protocol/nolus-core/releases/download/${VERSION_TAG}/nolusd?checksum=$HASH\"}}"
echo $JSON > $METADATA_FILE
- name: Upload metadata
uses: actions/upload-artifact@v4
with:
name: metadata
path: |
${{ env.METADATA_FILE }}
${{ env.CHECKSUM_FILE }}
# Drafts a release
release:
name: Draft release
runs-on: ubuntu-latest
needs: build-binary
needs: [build-binary, add-meta]
permissions: write-all

steps:
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4

- name: Display structure of downloaded files
run: ls -R
Expand All @@ -136,4 +169,6 @@ jobs:
prerelease: false
draft: true
files: |
nolusd-tar-${{ env.VERSION_TAG }}
nolusd-${{ env.VERSION_TAG }}
metadata
34 changes: 0 additions & 34 deletions .github/workflows/lint.yaml

This file was deleted.

58 changes: 0 additions & 58 deletions .github/workflows/test.yaml

This file was deleted.

0 comments on commit 1c54fa4

Please sign in to comment.