Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

merge: PR #197 from astrodevs-labs/feature/180-auto-generated-user-do… #53

merge: PR #197 from astrodevs-labs/feature/180-auto-generated-user-do…

merge: PR #197 from astrodevs-labs/feature/180-auto-generated-user-do… #53

Workflow file for this run

name: Tag and publish
on:
push:
branches:
- main
- dev
workflow_dispatch:
jobs:
find-last-commit:
runs-on: ubuntu-latest
outputs:
commit: ${{ steps.last-commit.outputs.commit }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Last Commit
id: last-commit
run: echo "commit=$(git log --oneline HEAD~1 -1 --format=format:%H)" >> $GITHUB_OUTPUT
setup:
needs: find-last-commit
uses: ./.github/workflows/detect-workspace-changes.yml
with:
from: ${{ github.sha }}
since: ${{ needs.find-last-commit.outputs.commit }}
publish-libraries:
if : ${{ needs.setup.outputs.libraries != '[]' }}
runs-on: ubuntu-latest
continue-on-error: true
needs: setup
strategy:
fail-fast: false
matrix:
workspace: ${{ fromJson(needs.setup.outputs.libraries)}}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: '18.16.1'
- id: setup-yarn
# Install yarn 3 & workspace-tools
run: |
corepack enable
corepack prepare yarn@stable --activate
yarn -v
- name: Install dependencies
run: |
yarn install --immutable
- name: Build
run: |
yarn workspace ${{ matrix.workspace.name }} build
- name: Publish
run: yarn workspace ${{ matrix.workspace.name }} run publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
compute-version:
if : ${{ needs.setup.outputs.extensions != '[]' }}
strategy:
fail-fast: false
matrix:
workspace: ${{ fromJson(needs.setup.outputs.extensions)}}
runs-on: ubuntu-latest
needs:
- setup
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: '18.16.1'
- id: setup-yarn
# Install yarn 3 & workspace-tools
run: |
corepack enable
corepack prepare yarn@stable --activate
yarn -v
- name: Get workspace path
id: workspace-path
run: |
echo "workspace-path=$(yarn workspaces info ${{ matrix.workspace.name }} --json | jq -r '.data[0].location')" >> $GITHUB_OUTPUT
- name: Check .unstable
id: check-unstable
run: |
cd ${{ steps.workspace-path.outputs.workspace-path }}
if [ -f ".unstable" ]; then
echo "is-unstable=true" >> $GITHUB_OUTPUT
else
echo "is-unstable=false" >> $GITHUB_OUTPUT
fi
- name: Get tag prefix
id: get-tag-prefix
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const workspace = "${{ matrix.workspace.name }}";
const language = workspace.split('-')[1];
return language;
- uses: paulhatch/semantic-version@d43966692519e4a5d4423b3da1b4b903c58c8f6b
id: find-new-version
with:
# The prefix to use to identify tags
tag_prefix: "${{ steps.get-tag-prefix.outputs.result }}-"
# A string which, if present in a git commit, indicates that a change represents a
# major (breaking) change, supports regular expressions wrapped with '/'
major_pattern: "!:"
# Same as above except indicating a minor change, supports regular expressions wrapped with '/'
minor_pattern: "/feat\\(?/"
# A string to determine the format of the version output
version_format: "${major}.${minor}.${patch}"
# If this is set to true, *every* commit will be treated as a new version.
bump_each_commit: false
# If true, the body of commits will also be searched for major/minor patterns to determine the version type.
search_commit_body: false
# Prevents pre-v1.0.0 version from automatically incrementing the major version.
# If enabled, when the major version is 0, major releases will be treated as minor and minor as patch. Note that the version_type output is unchanged.
enable_prerelease_mode: ${{ steps.check-unstable.outputs.is-unstable }}
- name: Normalize version
uses: actions/github-script@v6
id: tag
with:
result-encoding: string
script: |
const fs = require('fs')
console.log("Change type is : ", "${{ steps.find-new-version.outputs.version_type}}")
if (fs.existsSync('.unstable') && "${{ steps.find-new-version.outputs.version_type}}" == "patch") {
const patch = parseInt('${{steps.find-new-version.outputs.patch}}', 10);
return "${{steps.find-new-version.outputs.major}}.${{steps.find-new-version.outputs.minor}}." + (patch + 1).toString();
} else
return "${{steps.find-new-version.outputs.major}}.${{steps.find-new-version.outputs.minor}}.${{steps.find-new-version.outputs.patch}}"
- name: Set tag
run: |
git tag "${{ steps.get-tag-prefix.outputs.result }}-${{ steps.tag.outputs.result }}"
git push origin "${{ steps.get-tag-prefix.outputs.result }}-${{ steps.tag.outputs.result }}"
publish-core:
if: ${{ needs.setup.outputs.extensions != '[]' }}
needs:
- setup
- publish-libraries
- compute-version
strategy:
fail-fast: false
matrix:
workspace: ${{ fromJson(needs.setup.outputs.extensions)}}
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: '18.16.1'
- id: setup-yarn
# Install yarn 3 & workspace-tools
run: |
corepack enable
corepack prepare yarn@stable --activate
yarn -v
- name: Install dependencies
run: |
yarn install --immutable
- name: Build
run: |
yarn workspace ${{ matrix.workspace.name }} core:build
- name: Publish
run: yarn workspace ${{ matrix.workspace.name }} run core:publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish-extensions:
if : ${{ needs.setup.outputs.extensions != '[]' }}
needs:
- setup
- publish-libraries
- compute-version
strategy:
fail-fast: false
matrix:
workspace: ${{ fromJson(needs.setup.outputs.extensions)}}
uses: ./.github/workflows/publish-extension.yml
with:
workspace: ${{ matrix.workspace.name }}
secrets:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
VSCE_PAT: ${{ secrets.VSCE_PAT }}