Skip to content

ci(no-changelog): fixing workflow files #168

ci(no-changelog): fixing workflow files

ci(no-changelog): fixing workflow files #168

name: Prepare Release
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
env:
NODE_VERSION: "18.x"
permissions: write-all
jobs:
prepare-artifacts:
name: Prepare Artifacts
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_APP_URL: ${{ vars.NEXT_PUBLIC_APP_URL }}
PRE_RELEASE_TAG: ${{ vars.PRE_RELEASE_TAG }}
AUTOMATION_USER_NAME: ${{ vars.AUTOMATION_USER_NAME }}
AUTOMATION_USER_EMAIL: ${{ vars.AUTOMATION_USER_EMAIL }}
SKIP_IGNITION_BUILD: true
outputs:
tag-name: ${{ steps.prepare-release.outputs.TAG_NAME }}
dependency-hash: ${{ steps.extract-dependencies.outputs.DEPENDENCY_HASH }}
rocketicons-tgz: ${{ steps.generated-pkg-name.outputs.PKG_FILE }}
rocketicons-artifact-id: ${{ contains(steps.prepare-release.outputs.TAG_NAME, 'release') == true && 'deployable-artifacts' || 'rocketicons-pkg' }}
vercel-url-alias: ${{ steps.branch-to-url.outputs.URL_ID }}${{ vars.VERCEL_ALIAS_DOMAIN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Extract Dependencies
id: extract-dependencies
run: echo "DEPENDENCY_HASH=$(npx --yes @rocketclimb/sh extract-dependencies)" >> $GITHUB_OUTPUT
- name: Cache node_modules
uses: actions/cache@v4
id: npm-cache
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-${{ steps.extract-dependencies.outputs.DEPENDENCY_HASH }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache icons
uses: actions/cache@v4
id: icons-cache
with:
path: |
packages/generator/icons
key: ${{ runner.os }}-icons-${{ hashFiles('packages/generator/src/definitions.ts') }}
restore-keys: |
${{ runner.os }}-icons-
- name: Install packages
if: steps.npm-cache.outputs.cache-hit != 'true'
run: |
npm config set @rocketclimb:registry https://npm.pkg.github.com
npm config set //npm.pkg.github.com/:_authToken ${{ secrets.GITHUB_TOKEN }}
SKIP_BUILD_ALL=true npm install
- name: Icons Fetch
if: steps.icons-cache.outputs.cache-hit != 'true'
run: npm run fetch --workspace=packages/generator
- name: Build All
run: npm run build-all
- name: Run tests
run: npm run test-all
- name: Setup git user
run: |
git config user.name ${{ env.AUTOMATION_USER_NAME }}
git config user.email ${{ env.AUTOMATION_USER_EMAIL }}
- name: Prepare tag or release
id: prepare-release
run: |
echo "TAG_NAME=$(npm run release | grep v)" >> $GITHUB_OUTPUT
- name: Build Ignition statics
run: npm run generate-statics:all-icons --workspace=packages/ignition
- name: Set output as environment variable
run: echo "TAG_NAME=${{ steps.prepare-release.outputs.TAG_NAME }}" >> $GITHUB_ENV
- name: Branch Name to Url
id: branch-to-url
run: |
echo "URL_ID=$(echo "${{ github.head_ref }}" | tr -s ' ' | tr '[:upper:]' '[:lower:]' | sed 's,[ /\.],-,g' | sed 's/--/-/g')" >> $GITHUB_OUTPUT
- name: Get genereated package name
id: generated-pkg-name
run: echo "PKG_FILE=$(ls -1 -t *.tgz | head -1)" >> $GITHUB_OUTPUT
- name: Generate artifact for tag ${{ steps.prepare-release.outputs.TAG_NAME }}
run: |
echo "${{ steps.prepare-release.outputs.TAG_NAME }}" >> .tagrc
- name: Upload tag artifact to release job
uses: actions/upload-artifact@v4
with:
name: tag-artifact
path: .tagrc
- name: Upload deployable artifacts to release job
if: contains(steps.prepare-release.outputs.TAG_NAME, 'release')
uses: actions/upload-artifact@v4
with:
name: deployable-artifacts
path: |
release-notes.md
${{ steps.generated-pkg-name.outputs.PKG_FILE }}
- name: Upload rocketicons tgz as artifact
if: contains(steps.prepare-release.outputs.TAG_NAME, 'release') == false
uses: actions/upload-artifact@v4
with:
name: rocketicons-pkg
path: ${{ steps.generated-pkg-name.outputs.PKG_FILE }}
- name: "Tar data-helpers"
working-directory: ./packages
run: tar -cvf data-helpers.tar ignition/src/app/data-helpers
- name: Upload data-helpers
uses: actions/upload-artifact@v4
with:
name: data-helpers
path: packages/data-helpers.tar
compression-level: 9
publish-ignition:
needs: prepare-artifacts
uses: ./.github/workflows/publish-ignition.yml
with:
dependencies-hash: ${{ needs.prepare-artifacts.outputs.dependency-hash }}
rocketicons-tgz: ${{ needs.prepare-artifacts.outputs.rocketicons-tgz }}
rocketicons-artifact-id: ${{ needs.prepare-artifacts.outputs.rocketicons-artifact-id }}
vercel-url-alias: ${{ needs.prepare-artifacts.outputs.vercel-url-alias }}
branch: ${{ github.head_ref }}
secrets:
token: ${{ secrets.VERCEL_TOKEN }}