From 7ad72de7ca86b8509f87f8f0d16c00f13747b380 Mon Sep 17 00:00:00 2001 From: Periyasamy Palanisamy Date: Tue, 10 Aug 2021 15:42:59 +0200 Subject: [PATCH] add ci workflow release yaml file Signed-off-by: Periyasamy Palanisamy --- .github/workflows/release.yaml | 85 ++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..2c09982 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,85 @@ +--- +name: Release +on: + workflow_run: + types: + - completed + workflows: + - 'ci' +jobs: + print-debug-info: + name: Print debug info for Release workflow + runs-on: ubuntu-latest + steps: + - uses: hmarr/debug-action@v2 + create-release: + name: Create release + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' && contains(github.event.workflow_run.head_branch, 'release/') }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + ref: refs/heads/${{github.event.workflow_run.head_branch}} + - name: Get tag + run: | + branch=${{github.event.workflow_run.head_branch}} + echo '::set-output name=tag::'${branch#release/} + id: get-tag-step + - name: Push tag ${{ steps.get-tag-step.outputs.tag }} + run: | + git status + git tag ${{ steps.get-tag-step.outputs.tag }} + git push origin ${{ steps.get-tag-step.outputs.tag }} -f + - name: Create release ${{ steps.get-tag-step.outputs.tag }} + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} + with: + tag_name: refs/tags/${{ steps.get-tag-step.outputs.tag }} + release_name: ${{ steps.get-tag-step.outputs.tag }} + draft: false + prerelease: false + update-dependent-repositories: + strategy: + matrix: + repository: + - cmd-forwarder-ovs + name: Update ${{ matrix.repository }} + needs: create-release + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' && contains(github.event.workflow_run.head_branch, 'release/') }} + steps: + - name: Get tag + run: | + branch=${{github.event.workflow_run.head_branch}} + echo '::set-output name=tag::'${branch#release/} + id: get-tag-step + - name: Create commit + run: | + echo "Update go.mod and go.sum to ${{ github.repository }}@${{ steps.get-tag-step.outputs.tag }}" >> /tmp/commit-message + - name: Checkout networkservicemesh/${{ matrix.repository }} + uses: actions/checkout@v2 + with: + path: networkservicemesh/${{ matrix.repository }} + repository: networkservicemesh/${{ matrix.repository }} + token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} + - uses: actions/setup-go@v1 + with: + go-version: 1.16 + - name: Update ${{ github.repository }} locally + working-directory: networkservicemesh/${{ matrix.repository }} + run: | + GOPRIVATE=github.com/networkservicemesh go get -u github.com/${{ github.repository }}@${{ steps.get-tag-step.outputs.tag }} + go mod tidy + git diff + - name: Push update to the ${{ matrix.repository }} + working-directory: networkservicemesh/${{ matrix.repository }} + run: | + echo Starting to update repositotry ${{ matrix.repository }} + git config --global user.email "nsmbot@networkservicmesh.io" + git config --global user.name "NSMBot" + git add go.mod go.sum + git commit -s -F /tmp/commit-message + git checkout -b ${{ github.event.workflow_run.head_branch }} + git push -f origin ${{ github.event.workflow_run.head_branch }}