Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub workflow for automatically updating index.js #187

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
action/
lib/
node_modules/
node_modules/
51 changes: 0 additions & 51 deletions .github/workflows/check-dist.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/check-pull-request-no-dist-change.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Pull request authors are not expected to update `action/index.js` themselves
name: Check no dist update
on:
pull_request:
# For simplicity determine if the file was changed using `paths` here (instead of running any diff command below)
# There are some limitations to this, but they most likely won't cause any issues here
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#git-diff-comparisons
paths:
- 'action/index.js'

permissions:
contents: read

jobs:
check-no-dist-update:
name: Check no dist update
runs-on: ubuntu-latest

steps:
- name: Check no dist update
# Fail unconditionally; this workflow is only run if the file has changed, see
# condition at the start of this file
run: |
echo "Pull requests should not update 'action/index.js'"
exit 1
25 changes: 15 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on: # rebuild any PRs and main branch changes
- main
- 'releases/*'

permissions:
contents: read

jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
Expand Down Expand Up @@ -35,14 +38,15 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Build action (pull request)
# Pull requests are not expected to update `dist/index.js` themselves; therefore build `dist/index.js`
# here before running integration test
if: github.event_name == 'pull_request'
- name: Build action
# Pull requests are not expected to update `action/index.js`, and pushes to the `main` branch
# might not have updated the file either (and rely on CI to do that), therefore build the
# action here first
run: |
npm clean-install
npm run build
npm run github_ci_all

- name: Run wrapper-validation-action
id: action-test
Expand Down Expand Up @@ -75,14 +79,15 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Build action (pull request)
# Pull requests are not expected to update `dist/index.js` themselves; therefore build `dist/index.js`
# here before running integration test
if: github.event_name == 'pull_request'
- name: Build action
# Pull requests are not expected to update `action/index.js`, and pushes to the `main` branch
# might not have updated the file either (and rely on CI to do that), therefore build the
# action here first
run: |
npm clean-install
npm run build
npm run github_ci_all

- name: Run wrapper-validation-action
id: action-test
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
schedule:
- cron: '24 4 * * 6'

permissions:
contents: read
# Allow uploading CodeQL results
security-events: write

jobs:
analyze:
name: Analyze
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/update-checksums-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ on:
# Support running workflow manually
workflow_dispatch:

permissions:
# Allow creation of branch for checksums file update
contents: write
# Allow creation of pull request
pull-requests: write

jobs:
update-checksums:
name: Update checksums
# Only run for Gradle repository, but not for forks
if: github.repository == 'gradle/wrapper-validation-action'
runs-on: ubuntu-latest

steps:
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/update-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Update `action/index.js`
on:
push:
branches:
- main

permissions:
# Allow the workflow to push the changed file to the repository
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

- name: Build and test
run: |
npm -v
node -v
npm clean-install
npm run github_ci_all

# To be safe, verify that either there are no changes or only `action/index.js` has changed
- name: Verify no unexpected changes
run: |
# Check for changes to any file other than `action/index.js`,
# see https://stackoverflow.com/a/29374503
# Note that this does not detect new untracked files
if ! git diff --exit-code --quiet -- . ':!action/index.js'; then
echo "Unexpected changes:"
git diff -- . ':!action/index.js'
exit 1
fi

# Commit and push changes; has no effect if the file 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 `action/index.js` on their branch (and the pull request)
if: github.repository == 'gradle/wrapper-validation-action'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'Update `action/index.js`'
file_pattern: 'action/index.js'
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,7 @@ lib/**/*

.idea/
*.iml

# Ignore `index.js` file created during build; it is copied by CI to a separate directory
# Otherwise authors of PRs would commit it, causing merge conflicts or erroneous merges
/dist
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
action/
lib/
node_modules/
node_modules/
14 changes: 7 additions & 7 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Release

* starting on `main`
* `npm install`
* `npm run all`
* Commit and push any changes to the `dist` directory. Wait for CI.
* `git tag v1.0.x && git push --tags` with the actual version number
* `git tag -f -a v1 && git push -f --tags`
* `npm clean-install`
* `npm run github_ci_all`
* if `action/index.js` has changed, commit and push the changes, then wait for CI to finish
* `git tag v2.x.y && git push --tags` with the actual version number
* `git tag -f -a v2 && git push -f --tags`
* go to https://github.com/gradle/wrapper-validation-action/releases
* edit and publish the now drafted `v1` release
* create a new release from the new full version number `v1.0.x`, list the fixed issues and publish the release
* edit and publish the now drafted `v2` release
* create a new release from the new full version number `v2.x.y`, list the fixed issues and publish the release
* go to https://github.com/marketplace/actions/gradle-wrapper-validation
* verify that it displays the latest README
* verify that the version dropdown displays the new version
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ outputs:

runs:
using: 'node20'
main: 'dist/index.js'
main: 'action/index.js'

branding:
icon: 'shield'
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"compile": "ncc build",
"test": "jest",
"build": "npm run check && npm run compile",
"all": "npm run build && npm test"
"all": "npm run build && npm test",
"github_ci_all": "npm run all && cp dist/index.js action/index.js"
},
"repository": {
"type": "git",
Expand Down