Merge pull request #1683 from RoadieHQ/changeset-release/main #1096
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: Publish Build | |
on: | |
workflow_dispatch: | |
push: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
needs_release: ${{ steps.release_check.outputs.needs_release }} | |
strategy: | |
matrix: | |
node-version: [18] | |
env: | |
CI: true | |
NODE_OPTIONS: --max-old-space-size=4096 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- run: yarn install --frozen-lockfile | |
- name: Fetch previous commit for release check | |
run: git fetch origin '${{ github.event.before }}' | |
- name: Check if release | |
id: release_check | |
run: node scripts/check-if-release.js | |
env: | |
COMMIT_SHA_BEFORE: '${{ github.event.before }}' | |
- name: build type declarations | |
run: yarn tsc | |
- name: build packages | |
run: yarn build | |
- name: Discord notification | |
if: ${{ failure() }} | |
uses: Ilshidur/[email protected] | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK }} | |
with: | |
args: 'Master build failed https://github.com/{{GITHUB_REPOSITORY}}/actions/runs/{{GITHUB_RUN_ID}}' | |
# A separate release build that is only run for commits that are the result of merging the "Version Packages" PR | |
# We can't re-use the output from the above step, but we'll have a guaranteed node_modules cache and | |
# only run the build steps that are necessary for publishing | |
release: | |
needs: build | |
if: needs.build.outputs.needs_release == 'true' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18] | |
env: | |
CI: 'true' | |
NODE_OPTIONS: --max-old-space-size=4096 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- run: yarn install --frozen-lockfile | |
- name: build type declarations | |
run: yarn tsc | |
- name: build packages | |
run: yarn backstage-cli repo build | |
- name: 'Login to npmjs npm repo .npmrc' | |
shell: bash | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_AUTH_TOKEN}}" >> .npmrc | |
echo "_auth = ${{ secrets.NPM_CONFIG__AUTH }}" >> .npmrc | |
echo "always-auth = true" >> .npmrc | |
# Publishes current version of packages that are not already present in the registry. | |
- name: Run publish | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "roadie-bot" | |
lerna publish from-package --yes --no-verify-access | |
# Creates the next available tag with format "release-<year>-<month>-<day>[.<n>]" | |
- name: Create a release tag | |
id: create_tag | |
run: node scripts/create-release-tag.js | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Convert the newly created tag into a release with changelog information | |
- name: Create release on GitHub | |
run: node scripts/create-github-release.js ${{ steps.create_tag.outputs.tag_name }} 1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Notify everyone about this on Discord | |
- name: Discord notification | |
uses: Ilshidur/[email protected] | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK }} | |
TAG_NAME: ${{ steps.create_tag.outputs.tag_name }} | |
with: | |
args: 'A new release has been published! https://github.com/RoadieHQ/roadie-backstage-plugins/releases/tag/{{TAG_NAME}}' |