Skip to content

release-workflow-telemetry #4

release-workflow-telemetry

release-workflow-telemetry #4

Workflow file for this run

name: release-workflow-telemetry
on:
workflow_dispatch:
inputs:
version_scale:
type: choice
description: Version Scale
default: patch
options:
- patch
- minor
- major
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.FORESIGHT_GITHUB_TOKEN }}
- name: Configure Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
- name: Use Node.js 16.x
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: https://registry.npmjs.org
- run: npm version ${{ github.event.inputs.version_scale }}
- run: |
git add .
git diff-index --quiet HEAD || git commit -m 'Increase package.json version [skip ci]'
git push origin HEAD
create-release:
runs-on: ubuntu-latest
needs: [update-version]
steps:
- uses: actions/checkout@v4
with:
# ref is required
# see:
# - https://github.com/actions/checkout/issues/439
# - https://github.com/actions/checkout/issues/461
ref: ${{ github.ref }}
- name: Set new package version
id: package-version
run: |
export PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo $PACKAGE_VERSION
if [[ -z $PACKAGE_VERSION ]]
then
echo "Couldn't get variable PACKAGE_VERSION."
exit 1
fi
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
- name: Create a GitHub release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.FORESIGHT_GITHUB_TOKEN }}
script: |
try {
const response = await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: `v${{ env.PACKAGE_VERSION }}`,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: `v${{ env.PACKAGE_VERSION }}`
});
} catch (error) {
core.setFailed(error.message);
}