From f30389ccae022382b10cb7af08ef444a3ab99fc2 Mon Sep 17 00:00:00 2001 From: Artem Derevnjuk Date: Thu, 4 Jun 2020 20:14:19 +0300 Subject: [PATCH] chore(workflow): improve deploy workflow --- .../workflows/{build.yml => auto-build.yml} | 5 +- .github/workflows/deploy.yml | 47 +++++++++++-------- .github/workflows/release.yml | 22 +++++++++ 3 files changed, 54 insertions(+), 20 deletions(-) rename .github/workflows/{build.yml => auto-build.yml} (70%) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/auto-build.yml similarity index 70% rename from .github/workflows/build.yml rename to .github/workflows/auto-build.yml index 5a3beb4b..d3d64de6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/auto-build.yml @@ -9,10 +9,13 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 + with: + token: ${{ secrets.GPR_TOKEN }} - uses: actions/setup-node@v1 with: node-version: 12 - run: npm ci -q - run: npm run lint + - run: npm run pretty - run: npm run build diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c544bb39..ccdd8725 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,41 +2,50 @@ name: Automated deploy on: push: - branches: - - master + tags: + - 'v*' jobs: - release: + prepare: runs-on: ubuntu-latest + outputs: + project_version: ${{ steps.project_version.outputs.value }} + project: ${{ steps.project.outputs.value }} steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v1 - with: - node-version: 12 - - run: npm ci - - run: npm run build - - run: npm run semantic-release - env: - NPM_TOKEN: ${{secrets.NPM_TOKEN}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + - id: project_version + run: echo ::set-output name=value::${GITHUB_REF/refs\/tags\//} + - id: project + run: echo ::set-output name=value::$(echo ${GITHUB_REPOSITORY#*/} | tr A-Z a-z) deploy: - needs: release runs-on: ubuntu-latest + needs: prepare + env: + PROJECT: ${{ needs.prepare.outputs.project }} + VERSION: ${{ needs.prepare.outputs.project_version }} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 + with: + token: ${{ secrets.GPR_TOKEN }} + - uses: actions/setup-node@v1 with: node-version: 12 - - run: npm version from-git - - run: npm ci + registry-url: 'https://registry.npmjs.org' + + - run: npm ci -q + - run: npm run build + - run: npm version --no-git-tag-version "$VERSION" - run: npm publish env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - uses: actions/setup-node@v1 with: + node-version: 12 registry-url: 'https://npm.pkg.github.com' scope: '@NeuraLegion' + - run: npm publish env: - NODE_AUTH_TOKEN: ${{secrets.GPR_TOKEN}} + NODE_AUTH_TOKEN: ${{ secrets.GPR_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..4f7f6264 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +name: Semantic release + +on: + push: + branches: + - master + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + token: ${{ secrets.GPR_TOKEN }} + - uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Semantic release + run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }}