Skip to content

Commit

Permalink
automatic deployment of go modules
Browse files Browse the repository at this point in the history
Signed-off-by: sandeep.nishad1 <[email protected]>
  • Loading branch information
sandeepnRES committed Aug 30, 2022
1 parent 028269b commit e029e76
Show file tree
Hide file tree
Showing 12 changed files with 361 additions and 105 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/deploy_auto-go-pkgs.yml

This file was deleted.

321 changes: 268 additions & 53 deletions .github/workflows/deploy_go-pkgs.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,291 @@
name: Deploy General Go Module
name: Deploy Go Modules

on:
# Allows this to be a reusable workflow
workflow_call:
inputs:
module:
description: 'Go Module name'
required: true
type: string
version:
description: 'Version for Go Release'
required: true
type: string
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
module:
description: 'Go Module name'
default: 'protos-go'
required: true
version:
description: 'Version for Go Release'
default: 'v0.0.0'
required: true
push:
branches:
- test
paths:
- 'common/protos-go/VERSION'
- 'core/network/fabric-interop-cc/libs/utils/VERSION'
- 'core/network/fabric-interop-cc/libs/assetexchange/VERSION'
- 'core/network/fabric-interop-cc/interfaces/asset-mgmt/VERSION'
- 'core/network/fabric-interop-cc/contracts/interop/VERSION'
- 'sdks/fabric/go-sdk/VERSION'

jobs:
release:
publish-protos:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Set current date as env
run: echo "RELEASE_DATE=$(date +%b\ %d,\ %Y)" >> $GITHUB_ENV

- name: Set module tag and description
run: |
echo "MODULE_TAG=common/protos-go" >> $GITHUB_ENV
echo "MODULE_DESC=GO Weaver Protos" >> $GITHUB_ENV
- name: Get Full path
- name: Set module version
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
working-directory: common/protos-go

- name: Create Release
id: protos-go-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.MODULE_TAG }}/${{ env.VERSION }}
release_name: ${{ env.VERSION }} - ${{ env.MODULE_DESC }} - ${{ env.RELEASE_DATE }}
body: |
- Go Module: `github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/${{ env.MODULE_TAG }}`
- Release: ${{ env.VERSION }}
- Readme: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ env.VERSION }}/${{ env.MODULE_TAG }}/README.md).
- Source: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ env.VERSION }}/${{ env.MODULE_TAG }})
draft: false
prerelease: false

- name: Wait for release to be reflected
run: sleep 300

publish-lib-utils:
if: always()
needs: publish-protos
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Set current date as env
run: echo "RELEASE_DATE=$(date +%b\ %d,\ %Y)" >> $GITHUB_ENV

- name: Set module tag and description
run: |
echo "MODULE_TAG=core/network/fabric-interop-cc/libs/utils" >> $GITHUB_ENV
echo "MODULE_DESC=GO Fabric Utils Library for Interoperation" >> $GITHUB_ENV
- name: Set module version
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
working-directory: core/network/fabric-interop-cc/libs/utils

- name: Build test
run: make build
working-directory: core/network/fabric-interop-cc/libs/utils

- name: Create Release
id: lib-utils-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.MODULE_TAG }}/${{ env.VERSION }}
release_name: ${{ env.VERSION }} - ${{ env.MODULE_DESC }} - ${{ env.RELEASE_DATE }}
body: |
- Go Module: `github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/${{ env.MODULE_TAG }}`
- Release: ${{ env.VERSION }}
- Readme: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ env.VERSION }}/${{ env.MODULE_TAG }}/README.md).
- Source: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ env.VERSION }}/${{ env.MODULE_TAG }})
draft: false
prerelease: false

- name: Wait for release to be reflected
run: sleep 300

publish-lib-asset-exchange:
if: always()
needs: publish-protos
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Set current date as env
run: echo "RELEASE_DATE=$(date +%b\ %d,\ %Y)" >> $GITHUB_ENV

- name: Set module tag and description
run: |
echo "MODULE_TAG=core/network/fabric-interop-cc/libs/assetexchange" >> $GITHUB_ENV
echo "MODULE_DESC=GO Fabric Library for Asset Exchange" >> $GITHUB_ENV
- name: Set module version
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
working-directory: core/network/fabric-interop-cc/libs/assetexchange

- name: Build test
run: make build
working-directory: core/network/fabric-interop-cc/libs/assetexchange

- name: Create Release
id: lib-asset-exchange-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.MODULE_TAG }}/${{ env.VERSION }}
release_name: ${{ env.VERSION }} - ${{ env.MODULE_DESC }} - ${{ env.RELEASE_DATE }}
body: |
- Go Module: `github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/${{ env.MODULE_TAG }}`
- Release: ${{ env.VERSION }}
- Readme: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ env.VERSION }}/${{ env.MODULE_TAG }}/README.md).
- Source: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ env.VERSION }}/${{ env.MODULE_TAG }})
draft: false
prerelease: false

- name: Wait for release to be reflected
run: sleep 300

publish-interface-asset-mgmt:
if: always()
needs: [publish-protos]
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Set current date as env
run: echo "RELEASE_DATE=$(date +%b\ %d,\ %Y)" >> $GITHUB_ENV

- name: Set module tag and description
run: |
echo "MODULE_TAG=core/network/fabric-interop-cc/interfaces/asset-mgmt" >> $GITHUB_ENV
echo "MODULE_DESC=GO Fabric Asset Management Interface" >> $GITHUB_ENV
- name: Set module version
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
working-directory: core/network/fabric-interop-cc/interfaces/asset-mgmt

- name: Build test
run: make build
working-directory: core/network/fabric-interop-cc/interfaces/asset-mgmt

- name: Create Release
id: asset-mgmt-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.MODULE_TAG }}/${{ env.VERSION }}
release_name: ${{ env.VERSION }} - ${{ env.MODULE_DESC }} - ${{ env.RELEASE_DATE }}
body: |
- Go Module: `github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/${{ env.MODULE_TAG }}`
- Release: ${{ env.VERSION }}
- Readme: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ env.VERSION }}/${{ env.MODULE_TAG }}/README.md).
- Source: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ env.VERSION }}/${{ env.MODULE_TAG }})
draft: false
prerelease: false

- name: Wait for release to be reflected
run: sleep 300

publish-interop-cc:
if: always()
needs: [publish-protos, publish-lib-utils, publish-lib-asset-exchange]
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Set current date as env
run: echo "RELEASE_DATE=$(date +%b\ %d,\ %Y)" >> $GITHUB_ENV

- name: Set module tag and description
run: |
echo "MODULE_TAG=core/network/fabric-interop-cc/contracts/interop" >> $GITHUB_ENV
echo "MODULE_DESC=GO Fabric Interop Chaincode" >> $GITHUB_ENV
- name: Set module version
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
working-directory: core/network/fabric-interop-cc/contracts/interop

- name: Build test
run: make build
working-directory: core/network/fabric-interop-cc/contracts/interop

- name: Create Release
id: interop-cc-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.MODULE_TAG }}/${{ env.VERSION }}
release_name: ${{ env.VERSION }} - ${{ env.MODULE_DESC }} - ${{ env.RELEASE_DATE }}
body: |
- Go Module: `github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/${{ env.MODULE_TAG }}`
- Release: ${{ env.VERSION }}
- Readme: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ env.VERSION }}/${{ env.MODULE_TAG }}/README.md).
- Source: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ env.VERSION }}/${{ env.MODULE_TAG }})
draft: false
prerelease: false

- name: Wait for release to be reflected
run: sleep 300

publish-go-sdk:
if: always()
needs: [publish-protos]
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Set current date as env
run: echo "RELEASE_DATE=$(date +%b\ %d,\ %Y)" >> $GITHUB_ENV

- name: Set module tag and description
run: |
if [ "${{ inputs.module }}" = "protos-go" ]; then
echo "MODULE_TAG=common/protos-go" >> $GITHUB_ENV
echo "MODULE_DESC=GO Weaver Protos" >> $GITHUB_ENV
elif [ "${{ inputs.module }}" = "interop" ]; then
echo "MODULE_TAG=core/network/fabric-interop-cc/contracts/interop" >> $GITHUB_ENV
echo "MODULE_DESC=GO Fabric Interop Chaincode" >> $GITHUB_ENV
elif [ "${{ inputs.module }}" = "utils" ]; then
echo "MODULE_TAG=core/network/fabric-interop-cc/libs/utils" >> $GITHUB_ENV
echo "MODULE_DESC=GO Fabric Utils Library for Interoperation" >> $GITHUB_ENV
elif [ "${{ inputs.module }}" = "assetexchange" ]; then
echo "MODULE_TAG=core/network/fabric-interop-cc/libs/assetexchange" >> $GITHUB_ENV
echo "MODULE_DESC=GO Fabric Library for Asset Exchange" >> $GITHUB_ENV
elif [ "${{ inputs.module }}" = "asset-mgmt" ]; then
echo "MODULE_TAG=core/network/fabric-interop-cc/interfaces/asset-mgmt" >> $GITHUB_ENV
echo "MODULE_DESC=GO Fabric Asset Management Interface" >> $GITHUB_ENV
elif [ "${{ inputs.module }}" = "go-sdk" ]; then
echo "MODULE_TAG=sdks/fabric/go-sdk" >> $GITHUB_ENV
echo "MODULE_DESC=GO Fabric Weaver SDK" >> $GITHUB_ENV
else
echo "Module not known to the workflow. Exiting."
exit 1
fi
- name: Create GO Release
id: go-release
- name: Set module version
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
working-directory: sdks/fabric/go-sdk

- name: Build test
run: make build
working-directory: sdks/fabric/go-sdk

- name: Create Release
id: go-sdk-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.MODULE_TAG }}/${{ inputs.version }}
release_name: ${{ inputs.version }} - ${{ env.MODULE_DESC }} - ${{ env.RELEASE_DATE }}
tag_name: ${{ env.MODULE_TAG }}/${{ env.VERSION }}
release_name: ${{ env.VERSION }} - ${{ env.MODULE_DESC }} - ${{ env.RELEASE_DATE }}
body: |
- Go Module: `github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/${{ env.MODULE_TAG }}`
- Release: ${{ inputs.version }}
- Readme: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ inputs.version }}/${{ env.MODULE_TAG }}/README.md).
- Source: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ inputs.version }}/${{ env.MODULE_TAG }})
- Release: ${{ env.VERSION }}
- Readme: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ env.VERSION }}/${{ env.MODULE_TAG }}/README.md).
- Source: [Here](https://github.com/${{ github.repository_owner }}/weaver-dlt-interoperability/blob/${{ env.MODULE_TAG }}/${{ env.VERSION }}/${{ env.MODULE_TAG }})
draft: false
prerelease: false
prerelease: false

- name: Wait for release to be reflected
run: sleep 300
Loading

0 comments on commit e029e76

Please sign in to comment.