From d225aaff04a884d6b3b9fd43f0a3671281e15ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Petruni=C4=87?= Date: Mon, 30 Nov 2020 14:15:05 +0100 Subject: [PATCH] add release flow --- .github/workflows/release.yml | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b64c5d3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,65 @@ +name: Release + +on: + push: + branches: + - 'master' + +jobs: + tag: + name: Check and Tag + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Create tag + id: tag + uses: butlerlogic/action-autotag@1.1.1 + with: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + strategy: package # Optional, since "package" is the default strategy + tag_prefix: "v" + outputs: + tag: ${{ steps.tag.outputs.tagname }} + version: ${{ steps.tag.outputs.version }} + + release: + name: Publish + runs-on: ubuntu-latest + needs: tag + if: needs.tag.outputs.tag != '' + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup Nodejs + uses: actions/setup-node@v1 + with: + node-version: "12.x" + registry-url: "https://registry.npmjs.org" + - name: Install dependencies + run: yarn install --non-interactive --frozen-lockfile + - name: Build + run: yarn run build + - name: Publish to npm registry + run: yarn publish --no-git-tag-version --no-commit-hooks --non-interactive + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ needs.tag.outputs.tag }} + body: "" + release_name: Release ${{ needs.tag.outputs.tag }} + #in case of failure + - name: Rollback on failure + if: failure() + uses: author/action-rollback@9ec72a6af74774e00343c6de3e946b0901c23013 + with: + id: ${{ steps.create_release.outputs.id }} + tag: ${{ needs.tag.outputs.tag }} + delete_orphan_tag: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file