Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): enable weaver deployment workflows triggered on tag release #2413

Merged
merged 1 commit into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 155 additions & 0 deletions .github/workflows/test_weaver-pre-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: CC-BY-4.0

name: Pre-release Test Weaver Module versions

on:
pull_request:
branches:
- main
paths:
- 'weaver/common/protos-java-kt/gradle.properties'
- 'weaver/core/network/corda-interop-app/gradle.properties'
- 'weaver/sdks/corda/gradle.properties'
- 'weaver/common/protos-js/package.json'
- 'weaver/sdks/fabric/interoperation-node-sdk/package.json'
- 'weaver/sdks/besu/node/package.json'
- 'weaver/common/protos-rs/pkg/Cargo.toml'
- 'weaver/core/drivers/corda-driver/VERSION'
- 'weaver/core/drivers/fabric-driver/VERSION'
- 'weaver/core/identity-management/iin-agent/VERSION'
- 'weaver/core/relay/VERSION'
- 'weaver/common/protos-go/VERSION'
- 'weaver/core/network/fabric-interop-cc/libs/utils/VERSION'
- 'weaver/core/network/fabric-interop-cc/libs/assetexchange/VERSION'
- 'weaver/core/network/fabric-interop-cc/interfaces/asset-mgmt/VERSION'
- 'weaver/core/network/fabric-interop-cc/contracts/interop/VERSION'
- 'weaver/sdks/fabric/go-sdk/VERSION'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
check_release:
outputs:
status: ${{ steps.early.outputs.status }}
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- name: Ignore if not a release PR
id: early
run : |
status="skip"
if echo "${{ github.event.pull_request.title }}" | grep -q "chore(release)"; then
status="continue"
fi
echo "status=$status" >> $GITHUB_OUTPUT

test_weaver_pre-release:
needs: check_release
if: needs.check_release.outputs.status == 'continue'
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/[email protected]

- name: Get release verison from PR title
run: |
# Assuming release PR follows pattern: chore(release): publish vA.B.C
# Split PR title by space, and take 3rd word
VERSION=$(echo "${{ github.event.pull_request.title }}" | cut -d ' ' -f 3)
# Strip "v" from version
VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "VERSION=$VERSION" >> $GITHUB_ENV

# Gradle
- name: check weaver/common/protos-java-kt/gradle.properties
run: cat gradle.properties | grep "version=" | grep $VERSION || exit 1
working-directory: weaver/common/protos-java-kt

- name: check weaver/core/network/corda-interop-app/gradle.properties
run: cat gradle.properties | grep "version=" | grep $VERSION || exit 1
working-directory: weaver/core/network/corda-interop-app

- name: check weaver/sdks/corda/gradle.properties
run: cat gradle.properties | grep "version=" | grep $VERSION || exit 1
working-directory: weaver/sdks/corda

- name: check weaver/core/drivers/corda-driver/gradle.properties
run: cat gradle.properties | grep "version=" | grep $VERSION || exit 1
working-directory: weaver/core/drivers/corda-driver

# NodeJS
- name: check weaver/common/protos-js/package.json
run: cat package.json | grep "version" | grep $VERSION || exit 1
working-directory: weaver/common/protos-js

- name: check weaver/sdks/fabric/interoperation-node-sdk/package.json
run: cat package.json | grep "version" | grep $VERSION || exit 1
working-directory: weaver/sdks/fabric/interoperation-node-sdk

- name: check weaver/sdks/besu/node/package.json
run: cat package.json | grep "version" | grep $VERSION || exit 1
working-directory: weaver/sdks/besu/node

- name: check weaver/core/drivers/fabric-driver/package.json
run: cat package.json | grep "version" | grep $VERSION || exit 1
working-directory: weaver/core/drivers/fabric-driver

- name: check weaver/core/identity-management/iin-agent/package.json
run: cat package.json | grep "version" | grep $VERSION || exit 1
working-directory: weaver/core/identity-management/iin-agent

# Rust
- name: check weaver/common/protos-rs/pkg/Cargo.toml
run: cat Cargo.toml | grep "^version" | grep $VERSION || exit 1
working-directory: weaver/common/protos-rs/pkg

- name: check weaver/core/relay/Cargo.toml
run: cat Cargo.toml | grep "^version" | grep $VERSION || exit 1
working-directory: weaver/core/relay

# Docker
- name: check weaver/core/drivers/corda-driver/VERSION
run: cat VERSION | grep $VERSION || exit 1
working-directory: weaver/core/drivers/corda-driver

- name: check weaver/core/drivers/fabric-driver/VERSION
run: cat VERSION | grep $VERSION || exit 1
working-directory: weaver/core/drivers/fabric-driver

- name: check weaver/core/identity-management/iin-agent/VERSION
run: cat VERSION | grep $VERSION || exit 1
working-directory: weaver/core/identity-management/iin-agent

- name: check weaver/core/relay/VERSION
run: cat VERSION | grep $VERSION || exit 1
working-directory: weaver/core/relay

# GO
# - name: check weaver/common/protos-go/VERSION
# run: cat VERSION | grep $VERSION || exit 1
# working-directory: weaver/common/protos-go
#
# - name: check weaver/core/network/fabric-interop-cc/libs/utils/VERSION
# run: cat VERSION | grep $VERSION || exit 1
# working-directory: weaver/core/network/fabric-interop-cc/libs/utils
#
# - name: check weaver/core/network/fabric-interop-cc/libs/assetexchange/VERSION
# run: cat VERSION | grep $VERSION || exit 1
# working-directory: weaver/core/network/fabric-interop-cc/libs/assetexchange
#
# - name: check weaver/core/network/fabric-interop-cc/interfaces/asset-mgmt/VERSION
# run: cat VERSION | grep $VERSION || exit 1
# working-directory: weaver/core/network/fabric-interop-cc/interfaces/asset-mgmt
#
# - name: check weaver/core/network/fabric-interop-cc/contracts/interop/VERSION
# run: cat VERSION | grep $VERSION || exit 1
# working-directory: weaver/core/network/fabric-interop-cc/contracts/interop
#
# - name: check weaver/sdks/fabric/go-sdk/VERSION
# run: cat VERSION | grep $VERSION || exit 1
# working-directory: weaver/sdks/fabric/go-sdk
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,31 @@ name: Deploy Corda Packages

on:
push:
branches:
- main
paths:
- 'common/protos-java-kt/gradle.properties'
- 'core/network/corda-interop-app/gradle.properties'
- 'sdks/corda/gradle.properties'
- 'core/drivers/corda-driver/VERSION'
# branches:
# - main
# paths:
# - 'common/protos-java-kt/gradle.properties'
# - 'core/network/corda-interop-app/gradle.properties'
# - 'sdks/corda/gradle.properties'
# - 'core/drivers/corda-driver/VERSION'
# - 'common/protos-go/VERSION'

tags:
- v*

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
publish-protos:
publish-protos-java-kt:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3.1.0

- name: Set up JDK 8
uses: actions/setup-java@v2
Expand All @@ -35,25 +43,40 @@ jobs:
echo "Using ${GITHUB_ACTOR} user."
echo "username=${GITHUB_ACTOR}" >> github.properties
echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.properties
echo "url=https://maven.pkg.github.com/${GITHUB_REPOSITORY_OWNER}/weaver-dlt-interoperability" >> github.properties
echo "url=https://maven.pkg.github.com/${GITHUB_REPOSITORY_OWNER}/cacti" >> github.properties
cat github.properties
working-directory: common/protos-java-kt
working-directory: weaver/common/protos-java-kt

- name: Update version
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
sed -i "s#version=.*#version=${VERSION}#g" gradle.properties
cat gradle.properties
working-directory: weaver/common/protos-java-kt

- name: Publish
run: |
make publish > out 2> error
exitStatus=$?
cat out
cat error
(cat error | grep "Received status code 409 from server: Conflict" && exit 0) || exit $exitStatus
working-directory: common/protos-java-kt
working-directory: weaver/common/protos-java-kt


publish-interop-app:
if: always()
needs: publish-protos
needs: publish-protos-java-kt
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3.1.0

- name: Set up JDK 8
uses: actions/setup-java@v2
Expand All @@ -66,28 +89,43 @@ jobs:
echo "Using ${GITHUB_ACTOR} user."
echo "username=${GITHUB_ACTOR}" >> github.properties
echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.properties
echo "url=https://maven.pkg.github.com/${GITHUB_REPOSITORY_OWNER}/weaver-dlt-interoperability" >> github.properties
echo "url=https://maven.pkg.github.com/${GITHUB_REPOSITORY_OWNER}/cacti" >> github.properties
cat github.properties
working-directory: core/network/corda-interop-app
working-directory: weaver/core/network/corda-interop-app

- name: Update version
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
sed -i "s#version=.*#version=${VERSION}#g" gradle.properties
cat gradle.properties
working-directory: weaver/core/network/corda-interop-app

- name: Build
run: make build
working-directory: core/network/corda-interop-app
working-directory: weaver/core/network/corda-interop-app

- name: Publish
run: |
make publish > out 2> error
exitStatus=$?
cat out
cat error
(cat error | grep "Received status code 409 from server: Conflict" && exit 0) || exit $exitStatus
working-directory: core/network/corda-interop-app
working-directory: weaver/core/network/corda-interop-app

publish-sdk:
if: always()
needs: [publish-protos, publish-interop-app]
needs: [publish-protos-java-kt, publish-interop-app]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3.1.0

- name: Set up JDK 8
uses: actions/setup-java@v2
Expand All @@ -100,28 +138,43 @@ jobs:
echo "Using ${GITHUB_ACTOR} user."
echo "username=${GITHUB_ACTOR}" >> github.properties
echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.properties
echo "url=https://maven.pkg.github.com/${GITHUB_REPOSITORY_OWNER}/weaver-dlt-interoperability" >> github.properties
echo "url=https://maven.pkg.github.com/${GITHUB_REPOSITORY_OWNER}/cacti" >> github.properties
cat github.properties
working-directory: sdks/corda
working-directory: weaver/sdks/corda

- name: Update version
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
sed -i "s#version=.*#version=${VERSION}#g" gradle.properties
cat gradle.properties
working-directory: weaver/sdks/corda

- name: Build
run: make build
working-directory: sdks/corda
working-directory: weaver/sdks/corda

- name: Publish
run: |
make publish > out 2> error
exitStatus=$?
cat out
cat error
(cat error | grep "Received status code 409 from server: Conflict" && exit 0) || exit $exitStatus
working-directory: sdks/corda
working-directory: weaver/sdks/corda

publish-driver-image:
if: ${{ always() && github.repository_owner == 'hyperledger-labs' }}
needs: [publish-protos, publish-interop-app, publish-sdk]
if: ${{ always() && github.repository_owner == 'hyperledger' }}
needs: [publish-protos-java-kt, publish-interop-app, publish-sdk]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3.1.0

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
Expand All @@ -135,20 +188,29 @@ jobs:
echo "Using ${GITHUB_ACTOR} user."
echo "username=${GITHUB_ACTOR}" >> github.properties
echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.properties
echo "url=https://maven.pkg.github.com/${GITHUB_REPOSITORY_OWNER}/weaver-dlt-interoperability" >> github.properties
echo "url=https://maven.pkg.github.com/${GITHUB_REPOSITORY_OWNER}/cacti" >> github.properties
cat github.properties
working-directory: core/drivers/corda-driver
working-directory: weaver/core/drivers/corda-driver

- name: Update version
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo -n $VERSION > VERSION
cat VERSION
working-directory: weaver/core/drivers/corda-driver

- name: Check if package already exists
run: (make check-if-tag-exists && echo "CORDA_DRIVER_PUSH=true" >> $GITHUB_ENV) || echo "CORDA_DRIVER_PUSH=false" >> $GITHUB_ENV
working-directory: core/drivers/corda-driver
working-directory: weaver/core/drivers/corda-driver

- name: Build and Push
if: ${{ env.CORDA_DRIVER_PUSH == 'true' }}
run: make push-image
working-directory: core/drivers/corda-driver
working-directory: weaver/core/drivers/corda-driver

- name: Push latest tag
if: ${{ env.CORDA_DRIVER_PUSH == 'true' }}
run: make push-image-latest
working-directory: core/drivers/corda-driver
working-directory: weaver/core/drivers/corda-driver
Loading