Skip to content

Commit

Permalink
feat: more modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Skylar Simoncelli committed Sep 19, 2024
1 parent fe573e8 commit 3b4c996
Show file tree
Hide file tree
Showing 17 changed files with 534 additions and 346 deletions.
168 changes: 41 additions & 127 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
name: Build, test, release and deploy

permissions:
id-token: write
contents: write
name: CD

on:
workflow_dispatch:
Expand All @@ -16,6 +12,10 @@ on:
required: true
type: string

permissions:
id-token: write
contents: write

env:
AWS_REGION: "eu-central-1"
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
Expand All @@ -39,26 +39,9 @@ jobs:
tag: ${{ inputs.tag }}

partner-chains-smart-contracts:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}

- name: Extract PCSC Release Info from flake.nix
id: extract-release
run: |
echo "Extracting PCSC release version from flake.nix..."
release=$(cat flake.nix | grep -Po 'url = "github:input-output-hk/partner-chains-smart-contracts/v\K[0-9.]+(?=";)')
echo "Release version: $release"
echo "::set-output name=release::$release"
- name: Call Download Artifact Workflow
uses: ./.github/workflows/modules/artifacts/download-pcsc-artifact.yml
with:
release: ${{ steps.extract-release.outputs.release }}
artifact: "Specify-your-artifact-name-here"
uses: ./.github/workflows/modules/artifacts/download-pcsc-artifact.yml
with:
sha: ${{ inputs.sha }}

local-environment-tests:
needs: [build-pc-artifacts, partner-chains-smart-contracts]
Expand All @@ -67,121 +50,52 @@ jobs:
tag: ${{ inputs.tag }}
image: ${{ secrets.ECR_REGISTRY_SECRET }}/substrate-node:${{ inputs.sha }}

pre-release-candidate:
runs-on: ubuntu-latest
needs: [local-environment]
steps:
- name: Set filename variables
id: set-filenames
run: |
echo "PARTNER_CHAINS_CLI_X86_64_LINUX=partner-chains-cli-${{ inputs.tag }}-x86_64-linux" >> $GITHUB_ENV
echo "PARTNER_CHAINS_NODE_X86_64_LINUX=partner-chains-node-${{ inputs.tag }}-x86_64-linux" >> $GITHUB_ENV
echo "PARTNER_CHAINS_CLI_X86_64_APPLE_DARWIN=partner-chains-cli-${{ inputs.tag }}-x86_64-apple-darwin" >> $GITHUB_ENV
echo "PARTNER_CHAINS_NODE_X86_64_APPLE_DARWIN=partner-chains-node-${{ inputs.tag }}-x86_64-apple-darwin" >> $GITHUB_ENV
echo "PARTNER_CHAINS_CLI_AARCH64_APPLE_DARWIN=partner-chains-cli-${{ inputs.tag }}-aarch64-apple-darwin" >> $GITHUB_ENV
echo "PARTNER_CHAINS_NODE_AARCH64_APPLE_DARWIN=partner-chains-node-${{ inputs.tag }}-aarch64-apple-darwin" >> $GITHUB_ENV
- name: Download Linux CLI artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.PARTNER_CHAINS_CLI_X86_64_LINUX }}
path: artifact-linux/

- name: Download Linux NODE artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.PARTNER_CHAINS_NODE_X86_64_LINUX }}
path: artifact-linux/

- name: Download macOS x86_64 CLI artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.PARTNER_CHAINS_CLI_X86_64_APPLE_DARWIN }}
path: artifact-macos-x86_64/

- name: Download macOS x86_64 NODE artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.PARTNER_CHAINS_NODE_X86_64_APPLE_DARWIN }}
path: artifact-macos-x86_64/

- name: Download macOS ARM64 CLI artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.PARTNER_CHAINS_CLI_AARCH64_APPLE_DARWIN }}
path: artifact-macos-arm64/

- name: Download macOS ARM64 NODE artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.PARTNER_CHAINS_NODE_AARCH64_APPLE_DARWIN }}
path: artifact-macos-arm64/

- name: Check if release already exists
id: check_release
run: |
tag="${{ inputs.tag }}"
release_response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/$tag")
if echo "$release_response" | grep -q '"message": "Not Found"'; then
echo "release_exists=false" >> $GITHUB_ENV
echo "::set-output name=release_exists::false"
else
echo "release_exists=true" >> $GITHUB_ENV
echo "::set-output name=release_exists::true"
echo "release_id=$(echo $release_response | jq -r .id)" >> $GITHUB_ENV
echo "::set-output name=release_id::$(echo $release_response | jq -r .id)"
fi
- name: Create draft release
id: create_release
if: ${{ steps.check_release.outputs.release_exists == 'false' }}
run: |
tag="${{ inputs.tag }}"
release_response=$(curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-d '{"tag_name": "'$tag'", "name": "'$tag'", "body": "Draft release for '$tag'", "draft": true}' \
"https://api.github.com/repos/${{ github.repository }}/releases")
echo "release_id=$(echo $release_response | jq -r .id)" >> $GITHUB_ENV
echo "::set-output name=release_id::$(echo $release_response | jq -r .id)"
- name: Upload artifacts to release
if: ${{ steps.check_release.outputs.release_exists == 'true' || steps.create_release.outputs.release_id != '' }}
run: |
release_id="${{ steps.create_release.outputs.release_id }}"
if [ -z "$release_id" ]; then
release_id="${{ steps.check_release.outputs.release_id }}"
fi
for artifact in "artifact-linux/${{ env.PARTNER_CHAINS_CLI_X86_64_LINUX }}" \
"artifact-linux/${{ env.PARTNER_CHAINS_NODE_X86_64_LINUX }}" \
"artifact-macos-x86_64/${{ env.PARTNER_CHAINS_CLI_X86_64_APPLE_DARWIN }}" \
"artifact-macos-x86_64/${{ env.PARTNER_CHAINS_NODE_X86_64_APPLE_DARWIN }}" \
"artifact-macos-arm64/${{ env.PARTNER_CHAINS_CLI_AARCH64_APPLE_DARWIN }}" \
"artifact-macos-arm64/${{ env.PARTNER_CHAINS_NODE_AARCH64_APPLE_DARWIN }}"; do
chmod +x "$artifact"
curl -s -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$artifact" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/$release_id/assets?name=$(basename $artifact)"
done
create-draft-release:
uses: ./.github/workflows/modules/release/create-draft-release.yml
with:
tag: ${{ inputs.tag }}
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

chain-specs:
needs: build-pc-artifacts
uses: ./.github/workflows/modules/chain-specs.yml
uses: ./.github/workflows/modules/artifacts/generate-chain-specs.yml
with:
sha: ${{ inputs.sha }}
tag: ${{ inputs.tag }}

deploy-staging-preview:
needs: chain-specs
uses: ./.github/workflows/modules/deploy/staging-preview-deploy.yml
with:
image: ${{ secrets.ECR_REGISTRY_SECRET }}/substrate-node:${{ inputs.sha }}
chain-spec-secret: staging-chain-spec-${{ inputs.sha }}
chain-spec-secret: staging-preview-chain-spec-${{ inputs.sha }}

staging-preview-tests:
needs: deploy-staging-preview
uses: ./.github/workflows/modules/tests/staging-preview-tests.yml

build-and-publish-ghcr-image:
needs: staging-preview-tests
uses: ./.github/workflows/modules/images/build-and-publish-ghcr-image.yml
with:
sha: ${{ inputs.sha }}
tag: ${{ inputs.tag }}
tag: ${{ inputs.tag }}

publish-release:
needs: staging-preview-tests
uses: ./.github/workflows/modules/release/publish-release.yml
with:
tag: ${{ inputs.tag }}
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

deploy-staging-preprod:
needs: staging-preview-tests
uses: ./.github/workflows/modules/deploy/staging-preprod-deploy.yml
with:
image: ${{ secrets.ECR_REGISTRY_SECRET }}/substrate-node:${{ inputs.sha }}
chain-spec-secret: staging-preprod-chain-spec-${{ inputs.sha }}

staging-preprod-tests:
needs: deploy-staging-preprod
uses: ./.github/workflows/modules/tests/staging-preprod-tests.yml
Loading

0 comments on commit 3b4c996

Please sign in to comment.