Skip to content

Commit

Permalink
Add Release Workflow (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
rwxdash authored Feb 27, 2023
1 parent 2a1b86d commit 2a79bfa
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/release.yml
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);
}

0 comments on commit 2a79bfa

Please sign in to comment.