release #9
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: "Release" | |
on: | |
workflow_dispatch: {} | |
repository_dispatch: | |
types: | |
- release | |
permissions: | |
contents: write | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: 'true' | |
token: ${{ secrets.ORG_GITHUB_TOKEN }} | |
- name: Fetch All Tags | |
run: git fetch --force --tags | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
registry-url: https://registry.npmjs.org | |
- name: Install dependencies | |
run: yarn install | |
- name: Bump release version | |
id: version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config user.name "OpsLevel Bots" | |
git config user.email "[email protected]" | |
if [ -n "$(ls .changes/unreleased 2>/dev/null)" ] | |
then | |
echo "Changes detected. Creating a new release." | |
yarn bump-version | |
else | |
echo "No changes detected. Skipping version bump." | |
fi | |
RELEASE_VERSION=$(awk -F'"' '/"version": ".+"/{ print $4; exit; }' package.json) | |
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT | |
if [ $(git tag -l v$RELEASE_VERSION | grep v$RELEASE_VERSION) ] | |
then | |
echo "Tag has already been pushed. Skipping tag creation." | |
else | |
echo "Tag has not been pushed. Creating tag." | |
git add . | |
git commit -m "Cut Release '$RELEASE_VERSION'" | |
git push origin HEAD | |
gh release delete $RELEASE_VERSION || true | |
git tag -f v$RELEASE_VERSION -m "Cut Release 'v$RELEASE_VERSION'" | |
git push -f origin refs/tags/v$RELEASE_VERSION | |
fi | |
- name: Release to npm | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
yarn clean | |
yarn install | |
yarn tsc | |
yarn build | |
if HAS_ARTIFACTS=$(npm publish --dry-run 2>&1 | grep dist) | |
then | |
npm publish | |
else | |
echo "No assets generated to publish. Failing release." | |
exit 1 | |
fi | |
- name: Report release to opsLevel | |
uses: opslevel/[email protected] | |
with: | |
integration_url: ${{ secrets.DEPLOY_INTEGRATION_URL }} | |
service: "backstage-plugin" |