Commit 9e47918a authored by daz's avatar daz Committed by Daz DeBoer
Browse files

Build and commit changes to 'dist' automatically

Instead of requiring that developers keep the 'dist' directory up-to-date,
this process is now automated via a workflow.
Whenever a commit is pushed to 'main' (or a 'release/**' branch), the workflow will
build the application and commit any changes to the 'dist' directory.
parent b64dafb1
Loading
Loading
Loading
Loading
+26
Changes for .github/workflows/ci-check-no-dist-update.yml: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
name: CI-check-no-dist-update

# Prohibit any change to 'dist/**' on a non-release branch
on:
  push:
    branches-ignore:
      - main
      - release/*
    paths:
      - dist**
  pull_request:
    paths:
      - dist/**

permissions:
  contents: read

jobs:
  fail-on-dist-update:
    runs-on: ubuntu-latest

    steps:
    - run: |
        echo "The 'dist' directory is auotmatically updated by the release process."
        echo "It should not be updated manually in a non-release branch or a pull request."
        exit 1
+50
Changes for .github/workflows/ci-update-dist.yml: 50 added lines, 0 removed lines.
Original line number Diff line number Diff line
name: CI-update-dist

on:
  workflow_dispatch:
  push:
    branches: 
      - main
      - release/**
    paths-ignore:
      - 'dist/**'

permissions:
  contents: write

jobs:
  update-dist:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4

    - name: Set up Node.js
      uses: actions/setup-node@v4
      with:
        node-version: 20
        cache: npm
        cache-dependency-path: sources/package-lock.json

    - name: Build distribution
      run: |
        npm clean-install
        npm run check
        npm run compile
      working-directory: sources
    
    - name: Copy the generated sources/dist directory to the top-level dist
      run: |
        cp -r sources/dist .

    # Commit and push changes; has no effect if the files did not change
    # Important: The push event will not trigger any other workflows, see
    # https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#commits-made-by-this-action-do-not-trigger-new-workflow-runs
    - name: Commit & push changes
      # Only run for the Gradle repository; otherwise when users create pull requests from their `main` branch
      # it would erroneously update `dist` on their branch (and the pull request)
      if: github.repository == 'gradle/actions'
      uses: stefanzweifel/git-auto-commit-action@v5
      with:
        commit_message: 'Update dist directory'
        file_pattern: dist
−47

File deleted.

+2
Changes for sources/.gitignore: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -102,3 +102,5 @@ __tests__/runner/*
.idea/
*.iml

# Local 'dist' directory within 'sources'. This is copied to ../dist by CI.
dist/
+4 −4
Changes for sources/package.json: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -8,10 +8,10 @@
    "prettier-write": "prettier --write 'src/**/*.ts'",
    "prettier-check": "prettier --check 'src/**/*.ts'",
    "lint": "eslint 'src/**/*.ts'",
    "compile-dependency-submission-main": "ncc build src/dependency-submission/main.ts --out ../dist/dependency-submission/main --source-map --no-source-map-register",
    "compile-dependency-submission-post": "ncc build src/dependency-submission/post.ts --out ../dist/dependency-submission/post --source-map --no-source-map-register",
    "compile-setup-gradle-main": "ncc build src/setup-gradle/main.ts --out ../dist/setup-gradle/main --source-map --no-source-map-register",
    "compile-setup-gradle-post": "ncc build src/setup-gradle/post.ts --out ../dist/setup-gradle/post --source-map --no-source-map-register",
    "compile-dependency-submission-main": "ncc build src/dependency-submission/main.ts --out dist/dependency-submission/main --source-map --no-source-map-register",
    "compile-dependency-submission-post": "ncc build src/dependency-submission/post.ts --out dist/dependency-submission/post --source-map --no-source-map-register",
    "compile-setup-gradle-main": "ncc build src/setup-gradle/main.ts --out dist/setup-gradle/main --source-map --no-source-map-register",
    "compile-setup-gradle-post": "ncc build src/setup-gradle/post.ts --out dist/setup-gradle/post --source-map --no-source-map-register",
    "compile": "npm-run-all --parallel compile-*",
    "check": "npm-run-all --parallel prettier-check lint",
    "format": "npm-run-all --parallel prettier-write lint",