Skip to content

Commit

Permalink
fix(infra): differentiate between tags and semvers (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
Talal Ashraf authored Feb 21, 2024
1 parent c454d48 commit 1ad088c
Showing 1 changed file with 35 additions and 19 deletions.
54 changes: 35 additions & 19 deletions .github/workflows/build-ampd-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,30 @@ on:
default: latest

jobs:
extract-semver:
runs-on: ubuntu-22.04
name: Validate tag and extract semver
outputs:
semver: ${{ steps.extract_semver.outputs.semver }}
steps:
- name: Extract semver from tag
id: extract_semver
run: |
echo "semver=$(echo ${{ github.event.inputs.tag }} | sed 's/ampd-//')" >> $GITHUB_OUTPUT
- name: Validate tag
env:
TAG: ${{ github.event.inputs.tag }}
SEMVER: ${{ steps.extract_semver.outputs.semver }}
run: |
if [[ $TAG =~ ampd-v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]]; then echo "Tag is okay" && exit 0; else echo "invalid tag" && exit 1; fi
aws s3 ls s3://axelar-releases/ampd/"$SEMVER" && echo "tag already exists, use a new one" && exit 1
release-binaries:
runs-on: ${{ matrix.os }}
needs: extract-semver
strategy:
matrix:
os: [ubuntu-22.04, macos-12]
Expand All @@ -28,13 +50,6 @@ jobs:
aws-region: us-east-2
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/ghwf-${{ github.event.repository.name }}

- name: Validate tag
env:
SEMVER: ${{ github.event.inputs.tag }}
run: |
if [[ $SEMVER =~ v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]]; then echo "Tag is okay" && exit 0; else echo "invalid tag" && exit 1; fi
aws s3 ls s3://axelar-releases/ampd/"$SEMVER" && echo "tag already exists, use a new one" && exit 1
- name: Checkout code
uses: actions/checkout@v4
with:
Expand All @@ -55,7 +70,7 @@ jobs:

- name: build and sign darwin binaries
env:
SEMVER: ${{ github.event.inputs.tag }}
SEMVER: ${{ needs.extract-semver.outputs.semver }}
if: matrix.os == 'macos-12'
run: |
OS="darwin"
Expand All @@ -78,7 +93,7 @@ jobs:
- name: build and sign linux binaries
env:
SEMVER: ${{ github.event.inputs.tag }}
SEMVER: ${{ needs.extract-semver.outputs.semver }}
if: matrix.os == 'ubuntu-22.04'
run: |
OS="linux"
Expand Down Expand Up @@ -121,10 +136,10 @@ jobs:
EXPECTED="Mach-O 64-bit executable arm64"
fi
fi
echo "Output: $OUTPUT"
echo "Expected: $EXPECTED"
if [[ "$OUTPUT" == *"$EXPECTED"* ]]; then
echo "The binary format is correct."
else
Expand Down Expand Up @@ -155,12 +170,13 @@ jobs:

- name: Upload binaries to S3
env:
S3_PATH: s3://axelar-releases/ampd/${{ github.event.inputs.tag }}
S3_PATH: s3://axelar-releases/ampd/${{ needs.extract-semver.outputs.semver }}
run: |
aws s3 cp ./ampdbin ${S3_PATH}/ --recursive
release-docker:
runs-on: ubuntu-22.04
needs: extract-semver
permissions:
contents: write
packages: write
Expand All @@ -187,14 +203,14 @@ jobs:
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and push docker images
run: |
make build-push-docker-images
env:
PLATFORM: linux/amd64
SEMVER: ${{ github.event.inputs.tag }}
SEMVER: ${{ needs.extract-semver.outputs.semver }}
run: |
make build-push-docker-images
combine-sign:
needs: release-docker
needs: [ release-docker, extract-semver ]
runs-on: ubuntu-22.04
permissions:
contents: write
Expand All @@ -213,14 +229,14 @@ jobs:
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Create multiarch manifest
env:
SEMVER: ${{ needs.extract-semver.outputs.semver }}
run: |
docker buildx imagetools create -t axelarnet/axelar-ampd:${SEMVER} \
axelarnet/axelar-ampd-linux-amd64:${SEMVER}
env:
SEMVER: ${{ github.event.inputs.tag }}
- name: Sign the images with GitHub OIDC
run: cosign sign --oidc-issuer https://token.actions.githubusercontent.com ${TAGS}
env:
TAGS: axelarnet/axelar-ampd:${{ github.event.inputs.tag }}
TAGS: axelarnet/axelar-ampd:${{ needs.extract-semver.outputs.semver }}
COSIGN_EXPERIMENTAL: 1

0 comments on commit 1ad088c

Please sign in to comment.