-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
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@v3 | ||
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@v3 | ||
with: | ||
node-version: "16.x" | ||
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@v3 | ||
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); | ||
} |