-
Notifications
You must be signed in to change notification settings - Fork 13
Add GitHub Actions workflows #27
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
base: master
Are you sure you want to change the base?
Changes from all commits
8d0df0e
4eea3ba
64caae1
ddb24a8
bf63db6
09e6510
4008c0f
edfa657
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ master ] | ||
| pull_request: | ||
| branches: [ master ] | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Use Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run linter | ||
| run: npm run lint | ||
|
|
||
| - name: Build project | ||
| run: npm run build | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to build the project to run a linter? Linters just statically analyze code files. Consider removing all this build stuff.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Continuous Integration, we fully check the project build and its errors both during the build and during the linter. |
||
|
|
||
| - name: Check build artifacts | ||
| run: | | ||
| ls -la dist/ | ||
| test -f dist/rater.js | ||
| test -f dist/rater.min.js | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: Deploy | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this actually deploy? Seems like all it does is increment the version number. Long term, I'd like to stop using version numbers, in order to simplify the deploy process. Simple deploys = better DX (developer experience). Eventually I want to get it added to https://gadget-deploy.toolforge.org/ so we have one click deploys. Anyway, if all this github action does is increment the version, I'd suggest removing it.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file does one more check just in case and creates built (minified+bundle) files when adding a version tag. This is useful because any user can download the file they need without having to go to production.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You create a tag "vNUMBER", the action sees it and deploys the files. |
||
|
|
||
| on: | ||
| push: | ||
| tags: [ 'v*' ] | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Use Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run linter | ||
| run: npm run lint | ||
|
|
||
| - name: Build project | ||
| run: npm run build | ||
|
|
||
| - name: Get tag message | ||
| if: startsWith(github.ref, 'refs/tags/') | ||
| id: tag_message | ||
| run: | | ||
| TAG_MESSAGE=$(git tag -l --format='%(contents)' ${{ github.ref_name }}) | ||
| echo "tag_message<<EOF" >> $GITHUB_OUTPUT | ||
| echo "$TAG_MESSAGE" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Create Release | ||
| if: startsWith(github.ref, 'refs/tags/') | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: ${{ github.ref_name }} | ||
| name: Release ${{ github.ref_name }} | ||
| draft: false | ||
| prerelease: false | ||
| body: | | ||
| ${{ steps.tag_message.outputs.tag_message }} | ||
|
|
||
| ## Build Artifacts | ||
| - `dist/rater.js` - Development build (unminified) | ||
| - `dist/rater.min.js` - Production build (minified) | ||
|
|
||
| ## Installation | ||
| Install the userscript by copying the contents of `dist/rater.min.js` into your userscript manager. | ||
| files: | | ||
| dist/rater.js | ||
| dist/rater.min.js | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to Linter? The idea being that in the future, we might add a different CI job that is for unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, this is the standard check file name used on GitHub. Are you sure you want to change it?