From 5473b6a3cc4b4900bd61360d0a64a78a7dd9267e Mon Sep 17 00:00:00 2001 From: Albert Safin Date: Mon, 18 Apr 2022 18:28:56 +0000 Subject: [PATCH] Add release.yaml workflow Signed-off-by: Albert Safin --- .github/workflows/release.yaml | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 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 00000000..cb216992 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,64 @@ +--- +name: Release + +on: + workflow_run: + types: + - completed + workflows: + - "ci" +jobs: + check-gomod-deps: + name: Check go.mod Dependencies + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' && contains(github.event.workflow_run.head_branch, 'release/') }} + outputs: + tag: ${{ steps.get-tag-step.outputs.tag }} + steps: + - name: Get tag + run: | + branch=${{github.event.workflow_run.head_branch}} + echo '::set-output name=tag::'${branch#release/} + id: get-tag-step + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + with: + ref: refs/heads/${{github.event.workflow_run.head_branch}} + + - name: Check go.mod deps + run: | + cat go.mod | + grep 'github.com/networkservicemesh/.* v' | + grep -v 'github.com/networkservicemesh/.* ${{ steps.get-tag-step.outputs.tag }}' || exit 0; + + exit 1; + + create-release: + name: Create Release + needs: check-gomod-deps + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' && contains(github.event.workflow_run.head_branch, 'release/') }} + outputs: + tag: ${{ needs.check-gomod-deps.outputs.tag }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + ref: refs/heads/${{github.event.workflow_run.head_branch}} + + - name: Push tag ${{ needs.check-gomod-deps.outputs.tag }} + run: | + git status + git tag ${{ needs.check-gomod-deps.outputs.tag }} + git push origin ${{ needs.check-gomod-deps.outputs.tag }} -f + + - name: Create release ${{ needs.check-gomod-deps.outputs.tag }} + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} + with: + tag_name: refs/tags/${{ needs.check-gomod-deps.outputs.tag }} + release_name: ${{ needs.check-gomod-deps.outputs.tag }} + draft: false + prerelease: false