Merge pull request #1089 from CleverCloud/release-please--branches--m… #14
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: publish | |
on: | |
push: | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]+' | |
- '[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+' | |
jobs: | |
pre-publish: | |
name: 'Extract version' | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version_parse.outputs.version }} | |
prerelease: ${{ steps.version_parse.outputs.prerelease }} | |
skip-publish: ${{ steps.version_parse.outputs.skip-publish }} | |
steps: | |
- name: 'Decode version from tag' | |
id: version_regex | |
uses: KyoriPowered/action-regex-match@v3 | |
with: | |
text: ${{ github.ref_name }} | |
regex: '^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(beta)\.(?:0|[1-9]\d*))?$' | |
- name: 'Parse version' | |
id: version_parse | |
if: steps.version_regex.outputs.match != '' | |
run: | | |
echo "prerelease=${{ steps.version_regex.outputs.group1 }}" >> $GITHUB_OUTPUT | |
echo "version=${{ steps.version_regex.outputs.match }}" >> $GITHUB_OUTPUT | |
echo "skip-publish=false" >> $GITHUB_OUTPUT | |
publish-npm: | |
name: 'Publish package to npm.js' | |
needs: pre-publish | |
if: needs.pre-publish.outputs.skip-publish == 'false' | |
runs-on: ubuntu-latest | |
steps: | |
- name: '[Prepare] Checkout' | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.ref_name }} | |
- name: '[Prepare] Setup Node.js' | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: 'package.json' | |
cache: 'npm' | |
- name: '[Prepare] Extract NPM tag' | |
id: npm_tag | |
run: p=${{ needs.pre-publish.outputs.prerelease }} && echo "tag=${p:-latest}" >> $GITHUB_OUTPUT | |
- name: '[Prepare] Install dependencies' | |
run: npm ci | |
- name: '[Publish] version ${{ github.ref_name }} with tag ${{ steps.npm_tag.outputs.tag }}' | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} | |
npm publish --access public --tag ${{ steps.npm_tag.outputs.tag }} | |
publish-cdn: | |
name: 'Publish CDN to CleverCloud' | |
needs: pre-publish | |
if: needs.pre-publish.outputs.skip-publish == 'false' | |
runs-on: ubuntu-latest | |
steps: | |
- name: '[Prepare] Checkout' | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.ref_name }} | |
- name: '[Prepare] Setup Node.js' | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: 'package.json' | |
cache: 'npm' | |
- name: '[Prepare] Install dependencies' | |
run: npm ci | |
- name: '[Build]' | |
env: | |
VERSION: ${{ github.ref_name }} | |
run: | | |
npm run cdn-release:build | |
- name: '[Publish] version ${{ github.ref_name }}' | |
env: | |
SMART_CDN_CELLAR_KEY_ID: ${{ secrets.SMART_CDN_CELLAR_KEY_ID }} | |
SMART_CDN_CELLAR_SECRET_KEY: ${{ secrets.SMART_CDN_CELLAR_SECRET_KEY }} | |
run: npm run cdn-release:publish ${{ github.ref_name }} |