mirror of
https://github.com/gradle/actions
synced 2024-11-23 18:02:13 +00:00
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.
This commit is contained in:
parent
b64dafb1c9
commit
9e47918adf
5 changed files with 82 additions and 51 deletions
26
.github/workflows/ci-check-no-dist-update.yml
vendored
Normal file
26
.github/workflows/ci-check-no-dist-update.yml
vendored
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
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
.github/workflows/ci-update-dist.yml
vendored
Normal file
50
.github/workflows/ci-update-dist.yml
vendored
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
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
.github/workflows/ci-verify-outputs.yml
vendored
47
.github/workflows/ci-verify-outputs.yml
vendored
|
@ -1,47 +0,0 @@
|
||||||
name: CI-verify-outputs
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- assigned
|
|
||||||
- review_requested
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- release/**
|
|
||||||
- dependabot/**
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
cache: npm
|
|
||||||
cache-dependency-path: sources/package-lock.json
|
|
||||||
- name: Build
|
|
||||||
run: |
|
|
||||||
npm -v
|
|
||||||
node -v
|
|
||||||
npm install
|
|
||||||
npm run build
|
|
||||||
working-directory: sources
|
|
||||||
|
|
||||||
- name: Compare the expected and actual dist/ directories
|
|
||||||
run: |
|
|
||||||
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
|
||||||
echo "Detected uncommitted changes after build. See status below:"
|
|
||||||
git diff
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
id: diff
|
|
||||||
|
|
||||||
# If index.js was different than expected, upload the expected version as an artifact
|
|
||||||
- uses: actions/upload-artifact@v4
|
|
||||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
|
||||||
with:
|
|
||||||
name: dist
|
|
||||||
path: dist/
|
|
2
sources/.gitignore
vendored
2
sources/.gitignore
vendored
|
@ -102,3 +102,5 @@ __tests__/runner/*
|
||||||
.idea/
|
.idea/
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
|
# Local 'dist' directory within 'sources'. This is copied to ../dist by CI.
|
||||||
|
dist/
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
"prettier-write": "prettier --write 'src/**/*.ts'",
|
"prettier-write": "prettier --write 'src/**/*.ts'",
|
||||||
"prettier-check": "prettier --check 'src/**/*.ts'",
|
"prettier-check": "prettier --check 'src/**/*.ts'",
|
||||||
"lint": "eslint '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-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-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-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-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-*",
|
"compile": "npm-run-all --parallel compile-*",
|
||||||
"check": "npm-run-all --parallel prettier-check lint",
|
"check": "npm-run-all --parallel prettier-check lint",
|
||||||
"format": "npm-run-all --parallel prettier-write lint",
|
"format": "npm-run-all --parallel prettier-write lint",
|
||||||
|
|
Loading…
Reference in a new issue