├── .all-contributorsrc ├── .eslintrc.js ├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ ├── feature_request.md │ └── question.md └── workflows │ ├── build.yml │ ├── labels.yml │ ├── stale.yml │ ├── test.yml │ └── versioning.yml ├── .gitignore ├── .husky ├── .gitignore └── pre-commit ├── .prettierrc ├── LICENSE ├── README.md ├── action.yml ├── doc ├── auto-publish-example.yml └── auto-publish-walkthrough.md ├── examples ├── compare_api_response.json └── github_context.json ├── lib └── index.js ├── package-lock.json ├── package.json ├── src └── main.ts └── tsconfig.json /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "version-check", 3 | "projectOwner": "EndBug", 4 | "commit": true, 5 | "contributors": [ 6 | { 7 | "login": "EndBug", 8 | "name": "Federico Grandi", 9 | "avatar_url": "https://avatars1.githubusercontent.com/u/26386270?v=4", 10 | "profile": "https://github.com/EndBug", 11 | "contributions": [ 12 | "code", 13 | "doc" 14 | ] 15 | }, 16 | { 17 | "login": "sergeyzwezdin", 18 | "name": "Sergey Zwezdin", 19 | "avatar_url": "https://avatars2.githubusercontent.com/u/800755?v=4", 20 | "profile": "https://blog.zwezdin.com/", 21 | "contributions": [ 22 | "ideas" 23 | ] 24 | }, 25 | { 26 | "login": "larskinn", 27 | "name": "Lars Kinn Ekroll", 28 | "avatar_url": "https://avatars1.githubusercontent.com/u/910569?v=4", 29 | "profile": "https://github.com/larskinn", 30 | "contributions": [ 31 | "bug" 32 | ] 33 | }, 34 | { 35 | "login": "hsalazr", 36 | "name": "Humberto", 37 | "avatar_url": "https://avatars1.githubusercontent.com/u/4967271?v=4", 38 | "profile": "http://www.hsalazar.xyz", 39 | "contributions": [ 40 | "code" 41 | ] 42 | }, 43 | { 44 | "login": "hmehta", 45 | "name": "Heikki Mehtänen", 46 | "avatar_url": "https://avatars3.githubusercontent.com/u/108334?v=4", 47 | "profile": "https://github.com/hmehta", 48 | "contributions": [ 49 | "code" 50 | ] 51 | }, 52 | { 53 | "login": "CJY0208", 54 | "name": "CJY", 55 | "avatar_url": "https://avatars1.githubusercontent.com/u/18415774?v=4", 56 | "profile": "https://github.com/CJY0208", 57 | "contributions": [ 58 | "ideas" 59 | ] 60 | }, 61 | { 62 | "login": "wasabigeek", 63 | "name": "Nicholas", 64 | "avatar_url": "https://avatars2.githubusercontent.com/u/4256705?v=4", 65 | "profile": "https://github.com/wasabigeek", 66 | "contributions": [ 67 | "ideas" 68 | ] 69 | }, 70 | { 71 | "login": "AlexRex", 72 | "name": "Alex Torres", 73 | "avatar_url": "https://avatars0.githubusercontent.com/u/2911626?v=4", 74 | "profile": "http://alextorres.me", 75 | "contributions": [ 76 | "code" 77 | ] 78 | }, 79 | { 80 | "login": "adamkudrna", 81 | "name": "Adam Kudrna", 82 | "avatar_url": "https://avatars2.githubusercontent.com/u/5614085?v=4", 83 | "profile": "https://www.adamkudrna.cz", 84 | "contributions": [ 85 | "ideas", 86 | "doc" 87 | ] 88 | }, 89 | { 90 | "login": "spinlud", 91 | "name": "spinlud", 92 | "avatar_url": "https://avatars0.githubusercontent.com/u/12783208?v=4", 93 | "profile": "https://ludik.xyz/music", 94 | "contributions": [ 95 | "bug" 96 | ] 97 | }, 98 | { 99 | "login": "JasonCubic", 100 | "name": "JasonCubic", 101 | "avatar_url": "https://avatars.githubusercontent.com/u/8921015?v=4", 102 | "profile": "https://github.com/JasonCubic", 103 | "contributions": [ 104 | "code" 105 | ] 106 | }, 107 | { 108 | "login": "Gerrit0", 109 | "name": "Gerrit Birkeland", 110 | "avatar_url": "https://avatars.githubusercontent.com/u/19329837?v=4", 111 | "profile": "https://gerritbirkeland.com", 112 | "contributions": [ 113 | "code" 114 | ] 115 | }, 116 | { 117 | "login": "Hirse", 118 | "name": "Jan Pilzer", 119 | "avatar_url": "https://avatars.githubusercontent.com/u/2564094?v=4", 120 | "profile": "https://github.com/Hirse", 121 | "contributions": [ 122 | "doc" 123 | ] 124 | }, 125 | { 126 | "login": "JackNUMBER", 127 | "name": "Antoine Cadoret", 128 | "avatar_url": "https://avatars.githubusercontent.com/u/2306550?v=4", 129 | "profile": "http://jacknumber.fr", 130 | "contributions": [ 131 | "doc" 132 | ] 133 | }, 134 | { 135 | "login": "kusyka911", 136 | "name": "Vladislav", 137 | "avatar_url": "https://avatars.githubusercontent.com/u/24293461?v=4", 138 | "profile": "https://github.com/kusyka911", 139 | "contributions": [ 140 | "code" 141 | ] 142 | }, 143 | { 144 | "login": "SwabianCoder", 145 | "name": "SwabianCoder", 146 | "avatar_url": "https://avatars.githubusercontent.com/u/43047586?v=4", 147 | "profile": "https://github.com/SwabianCoder", 148 | "contributions": [ 149 | "bug" 150 | ] 151 | }, 152 | { 153 | "login": "bayssmekanique", 154 | "name": "Zach Cardoza", 155 | "avatar_url": "https://avatars.githubusercontent.com/u/2280384?v=4", 156 | "profile": "https://zachcardoza.com", 157 | "contributions": [ 158 | "bug" 159 | ] 160 | }, 161 | { 162 | "login": "HarelM", 163 | "name": "Harel M", 164 | "avatar_url": "https://avatars.githubusercontent.com/u/3269297?v=4", 165 | "profile": "https://github.com/HarelM", 166 | "contributions": [ 167 | "doc" 168 | ] 169 | }, 170 | { 171 | "login": "Tpleme", 172 | "name": "Leandro Melo", 173 | "avatar_url": "https://avatars.githubusercontent.com/u/72796924?v=4", 174 | "profile": "https://www.linkedin.com/in/leandro-melo-8b17021ba/", 175 | "contributions": [ 176 | "maintenance" 177 | ] 178 | }, 179 | { 180 | "login": "mrkpatchaa", 181 | "name": "Médédé Raymond KPATCHAA", 182 | "avatar_url": "https://avatars.githubusercontent.com/u/1266755?v=4", 183 | "profile": "https://mrkpatchaa.com", 184 | "contributions": [ 185 | "bug" 186 | ] 187 | }, 188 | { 189 | "login": "christulin", 190 | "name": "Chris Tulin", 191 | "avatar_url": "https://avatars.githubusercontent.com/u/47799223?v=4", 192 | "profile": "https://github.com/christulin", 193 | "contributions": [ 194 | "code" 195 | ] 196 | }, 197 | { 198 | "login": "khurrambilalaurecon", 199 | "name": "Khurram", 200 | "avatar_url": "https://avatars.githubusercontent.com/u/101312231?v=4", 201 | "profile": "https://github.com/khurrambilalaurecon", 202 | "contributions": [ 203 | "bug" 204 | ] 205 | } 206 | ], 207 | "files": [ 208 | "README.md" 209 | ], 210 | "commitType": "docs", 211 | "commitConvention": "angular", 212 | "contributorsPerLine": 7 213 | } 214 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | commonjs: true, 4 | es6: true, 5 | node: true 6 | }, 7 | extends: [ 8 | 'eslint:recommended', 9 | 'plugin:@typescript-eslint/recommended', 10 | 'plugin:prettier/recommended' 11 | ], 12 | globals: {}, 13 | parser: '@typescript-eslint/parser', 14 | parserOptions: { 15 | ecmaVersion: 6, 16 | sourceType: 'module' 17 | }, 18 | plugins: ['@typescript-eslint'], 19 | rules: { 20 | 'prettier/prettier': 'warn', 21 | 'no-cond-assign': [2, 'except-parens'], 22 | 'no-unused-vars': 0, 23 | '@typescript-eslint/no-unused-vars': 1, 24 | 'no-empty': [ 25 | 'error', 26 | { 27 | allowEmptyCatch: true 28 | } 29 | ], 30 | 'prefer-const': [ 31 | 'warn', 32 | { 33 | destructuring: 'all' 34 | } 35 | ], 36 | 'spaced-comment': 'warn' 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | lib/* linguist-generated 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [endbug] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report something that isn't working as expected 4 | title: "[Bug]" 5 | labels: 'status: pending' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Include the commit you made, the way you configured the step in your workflow and how you're using the outputs. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **Additional context** 23 | Add any other context about the problem here. 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Security issues 4 | url: https://github.com/EndBug 5 | about: For security vulnerabilities, please contact me in private 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[Feature]" 5 | labels: 'type: enhancement' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Question about how to use the action 4 | title: '' 5 | labels: 'type: question' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: 3 | push: 4 | branches: 5 | - main 6 | paths: 7 | - 'src/**' 8 | - 'package.json' 9 | - '.github/workflows/build.yml' 10 | 11 | jobs: 12 | build: 13 | name: Build compiled JS version 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v4 18 | 19 | - name: Set up Node.js 20 | uses: actions/setup-node@v4 21 | with: 22 | node-version: 20.x 23 | cache: npm 24 | 25 | - name: Install dependencies 26 | run: npm install 27 | 28 | - name: Compile TypeScript into compressed JavaScript 29 | run: npm run build 30 | 31 | - name: Commit changes 32 | uses: EndBug/add-and-commit@v9 33 | with: 34 | add: lib 35 | message: '[auto] build: update compiled version' 36 | push: --force 37 | -------------------------------------------------------------------------------- /.github/workflows/labels.yml: -------------------------------------------------------------------------------- 1 | name: 'Sync labels' 2 | on: 3 | workflow_dispatch: 4 | 5 | jobs: 6 | sync: 7 | uses: EndBug/workflows/.github/workflows/labels.yml@main 8 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: 'Handle stale issues and PR' 2 | on: 3 | schedule: 4 | - cron: '00 5,17 * * *' 5 | workflow_dispatch: 6 | 7 | jobs: 8 | stale: 9 | uses: EndBug/workflows/.github/workflows/stale.yml@main 10 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | push: 4 | pull_request: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | build: 9 | name: Test build 10 | runs-on: ubuntu-20.04 11 | steps: 12 | - uses: actions/checkout@v4 13 | - run: npm i 14 | - run: npm run build 15 | 16 | lint: 17 | name: Check linting 18 | runs-on: ubuntu-20.04 19 | steps: 20 | - uses: actions/checkout@v4 21 | - run: npm i 22 | - run: npm run lint 23 | -------------------------------------------------------------------------------- /.github/workflows/versioning.yml: -------------------------------------------------------------------------------- 1 | name: Update tags 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | actions-tagger: 9 | runs-on: windows-latest 10 | steps: 11 | - uses: Actions-R-Us/actions-tagger@v2 12 | with: 13 | publish_latest_tag: true 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | npm run build 2 | git add lib 3 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "tabWidth": 2, 5 | "useTabs": false, 6 | "trailingComma": "none" 7 | } 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Federico Grandi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Version check 2 | 3 | 4 | [![All Contributors](https://img.shields.io/badge/all_contributors-22-orange.svg?style=flat-square)](#contributors-) 5 | 6 | 7 | You can use this GitHub action to check whether your npm package version has been updated: this can be extremely helpful if you want to automate your release process. 8 | 9 | The main difference between this action and many others out there is that this doesn't do a specific task (it doesn't publish to registries, create tags or releases, send notifications, ...) but instead gives you an output that you can use in other steps of your workflow as you prefer: this way you don't have to deal with stuff you don't care about ;) 10 | 11 | This action is heavily inspired by [`npm-publish-action`](https://github.com/pascalgn/npm-publish-action) by [pascal](https://github.com/pascalgn): if you only care about publishing your package to npm automatically, this is the simplest solution :thumbsup: 12 | 13 | ## Usage 14 | 15 | ### GitHub Workflow 16 | 17 | You have to set up a step like this in your workflow (this assumes you've already [checked out](https://github.com/actions/checkout) your repo and [set up Node](https://github.com/actions/setup-node)): 18 | 19 | ```yaml 20 | - id: check # This will be the reference for getting the outputs. 21 | uses: EndBug/version-check@v2 # You can choose the version/branch you prefer. 22 | 23 | with: 24 | # All these parameters are optional, 25 | # check their descriptions to see if you need them. 26 | 27 | # Whether to search in every commit's diff. 28 | # This is useful if you often do change the version without saying it in the 29 | # commit message. If you always include the semver of the new version in your 30 | # commit message when you bump versions then you can omit this. 31 | # Default: false 32 | diff-search: true 33 | 34 | # You can use this to indicate a custom path to your `package.json`. If you keep 35 | # your package file in the root directory (which is the usual approach) you can 36 | # omit this. 37 | # Default: package.json 38 | file-name: ./your/own/dir/someName.json 39 | 40 | # You can put your bearer GitHub token here. This is needed only when running 41 | # the action on private repostiories, if you're running it on a public repo you 42 | # can omit this. 43 | # If you need to set this, you can use the built-in `GITHUB_TOKEN` secret that 44 | # GitHub generates for your repo's actions: you can find more info about it here: 45 | # https://help.github.com/en/github/automating-your-workflow-with-github-actions/virtual-environments-for-github-actions#github_token-secret 46 | # Default: '' 47 | token: ${{ secrets.GITHUB_TOKEN }} 48 | 49 | # You can use this to make the action use an URL to get the package file, 50 | # instead of using the one in your repo. 51 | # Please note that the action will expect the version from that package file to 52 | # be the same as the one that has been added in the commit: if you want to 53 | # change this behavior take a look at the `assume-same-version` option. 54 | # You can also set this to '::before', and the action will use the file from 55 | # before the push event. 56 | # Default: '' 57 | file-url: https://unpkg.com/pkg/package.json 58 | 59 | # You can use this to make the action use the current version (either from the 60 | # local file or the provided URL, see the `file-url` option) as either the added 61 | # or deleted version. 62 | # Accepted values are 'new' (if you want that version to be the "added" one) and 63 | # 'old' (to make it the "deleted" one). 64 | # Default: '' 65 | assume-same-version: old 66 | 67 | # You can use this option to make the action check the local version against the 68 | # remote one (from the provided URL, see the `file-url` option). 69 | # Accepted values are 'localIsNew' (if you expect the local version to be newer 70 | # than the remote one) and `remoteIsNew`. 71 | # Please note that using the wrong value may make the action detect the change 72 | # but fail to identify the type. 73 | # Default: '' 74 | static-checking: localIsNew 75 | 76 | # If you are using an instance of GitHub Enterprise you can use this option to 77 | # change the location of your GitHub api url. 78 | # Default: 'https://api.github.com' 79 | github-api-url: https://git.contoso.com/api/v3 80 | ``` 81 | 82 | Now, when someone changes the version in `package.json` to `1.2.3` and pushes a commit with the message ` 1.2.3` (eg. `Release 1.2.3` or `Bump version to v1.2.3`), output values are set (see Outputs below). 83 | 84 | Please note that even if the action is built to be easier as possible to use, it is still subject to GitHub API's limits. That means that pushes and PRs that have a lot of commits may not show 100% of the commits. It is not something to worry about though, since the action has always worked in most of the cases ;) 85 | 86 | ### Outputs 87 | 88 | - `changed`: either "true" or "false", indicates whether the version has changed. 89 | - `type`: if the version has changed, it tries to find the type of bump (e.g. "patch", "minor", ...). To see the full list of available types, please refer to the [`semver-diff` docs](https://github.com/sindresorhus/semver-diff/blob/1f2ac09e19213122094b9c49c7ac9bf4089da93b/readme.md) 90 | - `version`: if the version has changed, it shows the version number (e.g. "1.0.2") 91 | - `commit`: if the version has changed, it shows the sha of the commit where the change has been found. 92 | 93 | To access these outputs, you need to access the context of the step you previously set up: you can find more info about steps contexts [here](https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions#steps-context). 94 | If you set your step id to `check` you'll find the outputs at `steps.check.outputs.OUTPUT_NAME`: you can use these outputs as conditions for other steps. 95 | Here's an example: 96 | 97 | ```yaml 98 | - name: Check if version has been updated 99 | id: check 100 | uses: EndBug/version-check@v2 101 | 102 | - name: Log when changed 103 | if: steps.check.outputs.changed == 'true' 104 | run: 'echo "Version change found in commit ${{ steps.check.outputs.commit }}! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"' 105 | 106 | - name: Log when unchanged 107 | if: steps.check.outputs.changed == 'false' 108 | run: 'echo "No version change :/"' 109 | ``` 110 | 111 | Please keep in mind that when the `static-checking` option is used the `commit` output is not given. 112 | 113 | ## Examples 114 | 115 | ### Publishing automatically to both NPM & GitHub Package Registry 116 | 117 | If you want to see how to publish automatically your package to both NPM & GPR, please see [this](doc/auto-publish-example.yml) example workflow ;) 118 | You can also find a more in-depth guide in this [here](doc/auto-publish-walkthrough.md). 119 | 120 | ### Static-checking with your latest version on NPM 121 | 122 | If you want to check whether the version has changed since your last published version on NPM, you can do it using `file-url` and `static-checking`: 123 | 124 | - `file-url`: you need to use something like a raw.githubusercontent.com or unpkg.com URL, an API that will give you a JSON response with your package file. 125 | - `static-checking`: you're expecting your last published version to be older than the one in your repo, so we'll use `localIsNew` 126 | 127 | ```yaml 128 | - id: check 129 | uses: EndBug/version-check@v2 130 | with: 131 | file-url: https://unpkg.com/your-package@latest/package.json 132 | static-checking: localIsNew 133 | ``` 134 | 135 | This step will have a `true` `changed` output every time our version is newer (there won't be any `commit` output). 136 | 137 | ## Contributors ✨ 138 | 139 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |
Federico Grandi
Federico Grandi

💻 📖
Sergey Zwezdin
Sergey Zwezdin

🤔
Lars Kinn Ekroll
Lars Kinn Ekroll

🐛
Humberto
Humberto

💻
Heikki Mehtänen
Heikki Mehtänen

💻
CJY
CJY

🤔
Nicholas
Nicholas

🤔
Alex Torres
Alex Torres

💻
Adam Kudrna
Adam Kudrna

🤔 📖
spinlud
spinlud

🐛
JasonCubic
JasonCubic

💻
Gerrit Birkeland
Gerrit Birkeland

💻
Jan Pilzer
Jan Pilzer

📖
Antoine Cadoret
Antoine Cadoret

📖
Vladislav
Vladislav

💻
SwabianCoder
SwabianCoder

🐛
Zach Cardoza
Zach Cardoza

🐛
Harel M
Harel M

📖
Leandro Melo
Leandro Melo

🚧
Médédé Raymond KPATCHAA
Médédé Raymond KPATCHAA

🐛
Chris Tulin
Chris Tulin

💻
Khurram
Khurram

🐛
178 | 179 | 180 | 181 | 182 | 183 | 184 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! 185 | 186 | ## License 187 | 188 | This action is distributed under the MIT license, check the [license](LICENSE) for more info. 189 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: Version Check 2 | author: Federico Grandi 3 | description: An action that allows you to check whether your npm package version has been updated 4 | 5 | inputs: 6 | diff-search: 7 | description: Whether to search the bump commit using diffs (recommended ONLY if not using standard 'npm version' commits) 8 | required: false 9 | default: 'false' 10 | file-name: 11 | description: A custom path to the package.json file 12 | required: false 13 | default: 'package.json' 14 | file-url: 15 | description: A URL to use to fetch the package file, instead of loading the local file 16 | required: false 17 | assume-same-version: 18 | description: Whether to use the version fetched from the package file as the old one or the new one (instead of looking at the diffs) 19 | required: false 20 | static-checking: 21 | description: Whether to check the package from the file-url against the local package, instead of running the usual checks 22 | required: false 23 | token: 24 | description: A GitHub token to use when running on private repos 25 | required: false 26 | default: ${{ github.token }} 27 | github-api-url: 28 | description: The URL for your GitHub API. Some users may be using GitHub Enterprise and need to change this value. 29 | required: false 30 | default: https://api.github.com 31 | 32 | outputs: 33 | changed: 34 | description: Whether the version has changed in the examined commits 35 | type: 36 | description: The type of version change, if detectable (e.g. 'patch') 37 | version: 38 | description: The detected version number 39 | commit: 40 | description: The SHA of the commit where the version change has been detected 41 | 42 | runs: 43 | using: node20 44 | main: 'lib/index.js' 45 | 46 | branding: 47 | icon: package 48 | color: green 49 | -------------------------------------------------------------------------------- /doc/auto-publish-example.yml: -------------------------------------------------------------------------------- 1 | name: Auto-publish 2 | on: push 3 | 4 | jobs: 5 | build: ... # If your package needs to be built, you can put that process here, so that it stays constantly updated 6 | 7 | publish: 8 | name: Publish to NPM & GitHub Package Registry 9 | runs-on: ubuntu-latest 10 | if: contains(github.ref, 'main') # Publish it only if the push comes from the main branch 11 | needs: build # We need to wait for the build to be committed before publishing 12 | 13 | steps: 14 | - name: Checkout repository 15 | uses: actions/checkout@v4 16 | with: 17 | ref: main 18 | 19 | - name: Check version changes 20 | uses: EndBug/version-check@v2 21 | id: check 22 | 23 | - name: Version update detected 24 | if: steps.check.outputs.changed == 'true' 25 | run: 'echo "Version change found! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"' 26 | 27 | - name: Set up Node.js for NPM 28 | if: steps.check.outputs.changed == 'true' 29 | uses: actions/setup-node@v4 30 | with: 31 | registry-url: 'https://registry.npmjs.org' 32 | 33 | - name: Install dependencies 34 | if: steps.check.outputs.changed == 'true' 35 | run: npm install --only=prod 36 | 37 | - name: Publish package to NPM 38 | if: steps.check.outputs.changed == 'true' 39 | run: npm publish 40 | env: 41 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 42 | 43 | - name: Set up Node.js for GPR 44 | if: steps.check.outputs.changed == 'true' 45 | uses: actions/setup-node@v4 46 | with: 47 | registry-url: 'https://npm.pkg.github.com/' 48 | scope: '@endbug' 49 | 50 | - name: Set up package for GPR # You need to make sure you package name has the scope needed for GPR 51 | if: steps.check.outputs.changed == 'true' 52 | run: npm run gpr-setup 53 | 54 | - name: Publish package to GPR 55 | if: steps.check.outputs.changed == 'true' 56 | run: npm publish 57 | env: 58 | NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 59 | -------------------------------------------------------------------------------- /doc/auto-publish-walkthrough.md: -------------------------------------------------------------------------------- 1 | _Note: the result of all these steps can be found [here][1], in the workflow file I actually used for my package._ 2 | 3 | ## 1. Making sure that the "publish" job gets executed on the version that has been just built 4 | 5 | The easiest way I found was just to put the two jobs in the same workflow, and having them both fire on every `push` event: the publish job was then limited to execute only if on the `main` branch and after the first one. 6 | 7 | - **Build job:** 8 | 9 | It needs to build the new version of the package, then **commit** it to the repository: committing is crucial because that allows the other job to pick the built version. To commit the changes made inside a workflow run, you can use one of my actions, [`add-and-commit`][2]: it will push the changes to the GitHub repository using a "fake" git user. 10 | You workflow job should look something like this: 11 | 12 | ```yml 13 | jobs: 14 | build: 15 | name: Build 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - name: Checkout repository 20 | uses: actions/checkout@v4 21 | 22 | - name: Set up Node.js 23 | uses: actions/setup-node@v4 24 | with: 25 | node-version: '20.x' 26 | 27 | - name: Install dependencies 28 | run: npm install --only=prod 29 | 30 | - name: Compile build 31 | run: npm run build # This can be whatever command you use to build your package 32 | 33 | - name: Commit changes 34 | uses: EndBug/add-and-commit@v9 35 | with: # More info about the arguments on the action page 36 | author_name: Displayed name 37 | author_email: Displayed email 38 | message: 'Message for the commit' 39 | add: local/path/to/built/version/"*.js --force 40 | ``` 41 | 42 | - **Publish job:** 43 | 44 | We want it to run only in the `main` branch after `build` is completed, so we can set it like this: 45 | 46 | ```yml 47 | publish: 48 | name: Publish to NPM & GitHub Package Registry 49 | runs-on: ubuntu-latest 50 | if: contains(github.ref, 'main') # This sets the branch 51 | needs: build # This makes it wait for the build job 52 | ``` 53 | 54 | ## 2. Detecting a version change 55 | 56 | I didn't find a good way to do that so I made another action, [`version-check`][3]: this action scans the commits of every push and tries to figure out whether they include a version change. Remeber to set eventual needed arguments/inputs! 57 | You need to set up these two steps: 58 | 59 | ```yml 60 | steps: 61 | - name: Checkout repository 62 | uses: actions/checkout@v4 63 | with: 64 | ref: main 65 | 66 | - name: Check version changes 67 | uses: EndBug/version-check@v2 # More info about the arguments on the action page 68 | id: check # This will be the reference for later 69 | ``` 70 | 71 | You could also use the `static-check` and `file-url` option to detect teh version change, but if more checks run at the same time this can make it try to publish it multiple times. 72 | 73 | ## 3. Using the results of the check to edit the behavior of the workflow 74 | 75 | [`version-check`][3] provides three outputs: `changed` (whether there has been an update), `type` (the type of update, like "patch", "minor", ...) and `version` (the new version). 76 | These outputs can be accessed through the [`steps` context][4] and you can use them to decide whether to run a step or not, using the [`if` property][5]. This is an example: 77 | 78 | ```yml 79 | # check is the id we gave to the check step in the previous paragraph 80 | - name: Version update detected 81 | if: steps.check.outputs.changed == 'true' 82 | run: 'echo "Version change found! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"' 83 | ``` 84 | 85 | ## 4. Publishing a package to NPM 86 | 87 | Publishing a package to NPM is pretty straight-forward: you only need to set up Node.js and then use `npm publish`, like you would on your own machine. The only difference is that you'll need a token to authenticate: you can create one on [npmjs.com][6]. After you created it DO NOT put it in the workflow itself: you can store it as a "secret", you can find more info about those [here][7]. 88 | In this example, I'll assume your secret is called `NPM_TOKEN`: 89 | 90 | ```yml 91 | - name: Set up Node.js for NPM 92 | if: steps.check.outputs.changed == 'true' 93 | uses: actions/setup-node@v1 94 | with: 95 | registry-url: 'https://registry.npmjs.org' # This is just the default registry URL 96 | 97 | - name: Install dependencies 98 | if: steps.check.outputs.changed == 'true' 99 | run: npm install 100 | 101 | - name: Publish the package to NPM 102 | if: steps.check.outputs.changed == 'true' 103 | run: npm publish 104 | env: 105 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # NPM will automatically authenticate with this 106 | ``` 107 | 108 | ## 5. Publishing a package to GitHub Package Registry 109 | 110 | As for now, GitHub Package Registry is not very pleasant to work with if you want to keep publishing your existing package to npm: that's why it requires packages to be scoped, and that can mess thing up (your package may not be scoped or be scoped under a different name). 111 | I found that the easiest way to deal with that is doing this workaround: 112 | 113 | - In your workflow, re-setup Node.js but adding GPR's registry URL and your name-scope 114 | - Create an npm script that edits your package.json so that it changes the original name of the package to the one you need to publish to GPR (scope included) 115 | - After calling that script in your workflow, use `npm publish` as before, but this time using the built-in `GITHUB_TOKEN` as `NODE_AUTH_TOKEN`. 116 | 117 | ```json 118 | { 119 | "name": "YourPackageName", 120 | ... 121 | "scripts": { 122 | "gpr-setup": "node scripts/gpr.js" 123 | } 124 | } 125 | ``` 126 | 127 | ```js 128 | // scripts/gpr.js 129 | 130 | const fs = require('fs') 131 | const { join } = require('path') 132 | 133 | // Get the package obejct and change the name 134 | const pkg = require('../package.json') 135 | pkg.name = '@yourscope/YourPackageName' 136 | 137 | // Update package.json with the udpated name 138 | fs.writeFileSync(join(__dirname, '../package.json'), JSON.stringify(pkg)) 139 | ``` 140 | 141 | ```yml 142 | - name: Set up Node.js for GPR 143 | if: steps.check.outputs.changed == 'true' 144 | uses: actions/setup-node@v1 145 | with: 146 | registry-url: 'https://npm.pkg.github.com/' 147 | scope: '@yourscope' 148 | 149 | - name: Set up the package for GPR 150 | if: steps.check.outputs.changed == 'true' 151 | run: npm run gpr-setup 152 | 153 | - name: Publish the package to GPR 154 | if: steps.check.outputs.changed == 'true' 155 | run: npm publish 156 | env: 157 | NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 158 | ``` 159 | 160 | ## Result 161 | 162 | Your package is now published both to NPM and GPR (a description needs to be manually added to GPR though). 163 | You can find all of the stuff I'm referring to in the 4.0.3 version of uptime-monitor: 164 | 165 | - [Build/publish workflow][1] 166 | - [GPR script][8] 167 | 168 | [1]: https://github.com/EndBug/uptime-monitor/blob/v4.0.3/.github/workflows/build-and-publish.yml 169 | [2]: https://github.com/marketplace/actions/add-commit 170 | [3]: https://github.com/marketplace/actions/version-check 171 | [4]: https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions#steps-context 172 | [5]: https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idif 173 | [6]: https://npmjs.com 174 | [7]: https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables 175 | [8]: https://github.com/EndBug/uptime-monitor/blob/v4.0.3/scripts/gpr.js 176 | -------------------------------------------------------------------------------- /examples/compare_api_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "https://api.github.com/repos/EndBug/temp-action-test/compare/56b7d23168709b71e09adde795b3a5234effb477...7a435d44be1182400597e276c652c4cea26c7f00", 3 | "html_url": "https://github.com/EndBug/temp-action-test/compare/56b7d23168709b71e09adde795b3a5234effb477...7a435d44be1182400597e276c652c4cea26c7f00", 4 | "permalink_url": "https://github.com/EndBug/temp-action-test/compare/EndBug:56b7d23...EndBug:7a435d4", 5 | "diff_url": "https://github.com/EndBug/temp-action-test/compare/56b7d23168709b71e09adde795b3a5234effb477...7a435d44be1182400597e276c652c4cea26c7f00.diff", 6 | "patch_url": "https://github.com/EndBug/temp-action-test/compare/56b7d23168709b71e09adde795b3a5234effb477...7a435d44be1182400597e276c652c4cea26c7f00.patch", 7 | "base_commit": { 8 | "sha": "56b7d23168709b71e09adde795b3a5234effb477", 9 | "node_id": "MDY6Q29tbWl0MjA5MTA4ODk2OjU2YjdkMjMxNjg3MDliNzFlMDlhZGRlNzk1YjNhNTIzNGVmZmI0Nzc=", 10 | "commit": { 11 | "author": { 12 | "name": "Federico Grandi", 13 | "email": "fgrandi30@gmail.com", 14 | "date": "2021-03-18T21:24:26Z" 15 | }, 16 | "committer": { 17 | "name": "GitHub", 18 | "email": "noreply@github.com", 19 | "date": "2021-03-18T21:24:26Z" 20 | }, 21 | "message": "Update main.yml", 22 | "tree": { 23 | "sha": "fc1e3672fd2a6020bce09b73d40224fde168e149", 24 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/trees/fc1e3672fd2a6020bce09b73d40224fde168e149" 25 | }, 26 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/commits/56b7d23168709b71e09adde795b3a5234effb477", 27 | "comment_count": 0, 28 | "verification": { 29 | "verified": true, 30 | "reason": "valid", 31 | "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJgU8UKCRBK7hj4Ov3rIwAAdHIIAHpf1MMLmSgqM/fZyr2asXuL\ncDIokj10QRIqH+MiCimX4JqkdbypWqsoH8sNBpTXL9tAAQEJQDNV9vRJgSkdrY7A\nQJzXNqd0C1vYGrLWijZCwvnPixRFMxMBFT8+3/b/Ib4Ror1FUJuqcMp+G0udarYb\noCgzFi5qVPV6zVl1sVIViegaEsBGD9623xN6167uaHTWtiqHJChFLt4FreM6mPz5\nDgtjwJtvwhubKT+CoqH6BINmBSKwWMRMvane9PORg6tI4m8XD6E3o7kNTCZ47H4l\nqzoRELk0nP+CYWikthVMTYmkUFXFQOaGnloC7dUMpO15mG5qcfLJE7dZ0D9crGQ=\n=zQtM\n-----END PGP SIGNATURE-----\n", 32 | "payload": "tree fc1e3672fd2a6020bce09b73d40224fde168e149\nparent 164077e1d543dd55aaa14b564a067d1e130372bb\nauthor Federico Grandi 1616102666 +0100\ncommitter GitHub 1616102666 +0100\n\nUpdate main.yml" 33 | } 34 | }, 35 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/56b7d23168709b71e09adde795b3a5234effb477", 36 | "html_url": "https://github.com/EndBug/temp-action-test/commit/56b7d23168709b71e09adde795b3a5234effb477", 37 | "comments_url": "https://api.github.com/repos/EndBug/temp-action-test/commits/56b7d23168709b71e09adde795b3a5234effb477/comments", 38 | "author": { 39 | "login": "EndBug", 40 | "id": 26386270, 41 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 42 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 43 | "gravatar_id": "", 44 | "url": "https://api.github.com/users/EndBug", 45 | "html_url": "https://github.com/EndBug", 46 | "followers_url": "https://api.github.com/users/EndBug/followers", 47 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 48 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 49 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 50 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 51 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 52 | "repos_url": "https://api.github.com/users/EndBug/repos", 53 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 54 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 55 | "type": "User", 56 | "site_admin": false 57 | }, 58 | "committer": { 59 | "login": "web-flow", 60 | "id": 19864447, 61 | "node_id": "MDQ6VXNlcjE5ODY0NDQ3", 62 | "avatar_url": "https://avatars.githubusercontent.com/u/19864447?v=4", 63 | "gravatar_id": "", 64 | "url": "https://api.github.com/users/web-flow", 65 | "html_url": "https://github.com/web-flow", 66 | "followers_url": "https://api.github.com/users/web-flow/followers", 67 | "following_url": "https://api.github.com/users/web-flow/following{/other_user}", 68 | "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", 69 | "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", 70 | "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", 71 | "organizations_url": "https://api.github.com/users/web-flow/orgs", 72 | "repos_url": "https://api.github.com/users/web-flow/repos", 73 | "events_url": "https://api.github.com/users/web-flow/events{/privacy}", 74 | "received_events_url": "https://api.github.com/users/web-flow/received_events", 75 | "type": "User", 76 | "site_admin": false 77 | }, 78 | "parents": [ 79 | { 80 | "sha": "164077e1d543dd55aaa14b564a067d1e130372bb", 81 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/164077e1d543dd55aaa14b564a067d1e130372bb", 82 | "html_url": "https://github.com/EndBug/temp-action-test/commit/164077e1d543dd55aaa14b564a067d1e130372bb" 83 | } 84 | ] 85 | }, 86 | "merge_base_commit": { 87 | "sha": "56b7d23168709b71e09adde795b3a5234effb477", 88 | "node_id": "MDY6Q29tbWl0MjA5MTA4ODk2OjU2YjdkMjMxNjg3MDliNzFlMDlhZGRlNzk1YjNhNTIzNGVmZmI0Nzc=", 89 | "commit": { 90 | "author": { 91 | "name": "Federico Grandi", 92 | "email": "fgrandi30@gmail.com", 93 | "date": "2021-03-18T21:24:26Z" 94 | }, 95 | "committer": { 96 | "name": "GitHub", 97 | "email": "noreply@github.com", 98 | "date": "2021-03-18T21:24:26Z" 99 | }, 100 | "message": "Update main.yml", 101 | "tree": { 102 | "sha": "fc1e3672fd2a6020bce09b73d40224fde168e149", 103 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/trees/fc1e3672fd2a6020bce09b73d40224fde168e149" 104 | }, 105 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/commits/56b7d23168709b71e09adde795b3a5234effb477", 106 | "comment_count": 0, 107 | "verification": { 108 | "verified": true, 109 | "reason": "valid", 110 | "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJgU8UKCRBK7hj4Ov3rIwAAdHIIAHpf1MMLmSgqM/fZyr2asXuL\ncDIokj10QRIqH+MiCimX4JqkdbypWqsoH8sNBpTXL9tAAQEJQDNV9vRJgSkdrY7A\nQJzXNqd0C1vYGrLWijZCwvnPixRFMxMBFT8+3/b/Ib4Ror1FUJuqcMp+G0udarYb\noCgzFi5qVPV6zVl1sVIViegaEsBGD9623xN6167uaHTWtiqHJChFLt4FreM6mPz5\nDgtjwJtvwhubKT+CoqH6BINmBSKwWMRMvane9PORg6tI4m8XD6E3o7kNTCZ47H4l\nqzoRELk0nP+CYWikthVMTYmkUFXFQOaGnloC7dUMpO15mG5qcfLJE7dZ0D9crGQ=\n=zQtM\n-----END PGP SIGNATURE-----\n", 111 | "payload": "tree fc1e3672fd2a6020bce09b73d40224fde168e149\nparent 164077e1d543dd55aaa14b564a067d1e130372bb\nauthor Federico Grandi 1616102666 +0100\ncommitter GitHub 1616102666 +0100\n\nUpdate main.yml" 112 | } 113 | }, 114 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/56b7d23168709b71e09adde795b3a5234effb477", 115 | "html_url": "https://github.com/EndBug/temp-action-test/commit/56b7d23168709b71e09adde795b3a5234effb477", 116 | "comments_url": "https://api.github.com/repos/EndBug/temp-action-test/commits/56b7d23168709b71e09adde795b3a5234effb477/comments", 117 | "author": { 118 | "login": "EndBug", 119 | "id": 26386270, 120 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 121 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 122 | "gravatar_id": "", 123 | "url": "https://api.github.com/users/EndBug", 124 | "html_url": "https://github.com/EndBug", 125 | "followers_url": "https://api.github.com/users/EndBug/followers", 126 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 127 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 128 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 129 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 130 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 131 | "repos_url": "https://api.github.com/users/EndBug/repos", 132 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 133 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 134 | "type": "User", 135 | "site_admin": false 136 | }, 137 | "committer": { 138 | "login": "web-flow", 139 | "id": 19864447, 140 | "node_id": "MDQ6VXNlcjE5ODY0NDQ3", 141 | "avatar_url": "https://avatars.githubusercontent.com/u/19864447?v=4", 142 | "gravatar_id": "", 143 | "url": "https://api.github.com/users/web-flow", 144 | "html_url": "https://github.com/web-flow", 145 | "followers_url": "https://api.github.com/users/web-flow/followers", 146 | "following_url": "https://api.github.com/users/web-flow/following{/other_user}", 147 | "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", 148 | "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", 149 | "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", 150 | "organizations_url": "https://api.github.com/users/web-flow/orgs", 151 | "repos_url": "https://api.github.com/users/web-flow/repos", 152 | "events_url": "https://api.github.com/users/web-flow/events{/privacy}", 153 | "received_events_url": "https://api.github.com/users/web-flow/received_events", 154 | "type": "User", 155 | "site_admin": false 156 | }, 157 | "parents": [ 158 | { 159 | "sha": "164077e1d543dd55aaa14b564a067d1e130372bb", 160 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/164077e1d543dd55aaa14b564a067d1e130372bb", 161 | "html_url": "https://github.com/EndBug/temp-action-test/commit/164077e1d543dd55aaa14b564a067d1e130372bb" 162 | } 163 | ] 164 | }, 165 | "status": "ahead", 166 | "ahead_by": 5, 167 | "behind_by": 0, 168 | "total_commits": 5, 169 | "commits": [ 170 | { 171 | "sha": "76499729dcc4d6112989249710649e7221e225dd", 172 | "node_id": "MDY6Q29tbWl0MjA5MTA4ODk2Ojc2NDk5NzI5ZGNjNGQ2MTEyOTg5MjQ5NzEwNjQ5ZTcyMjFlMjI1ZGQ=", 173 | "commit": { 174 | "author": { 175 | "name": "Federico Grandi", 176 | "email": "fgrandi30@gmail.com", 177 | "date": "2021-03-18T21:25:59Z" 178 | }, 179 | "committer": { 180 | "name": "GitHub", 181 | "email": "noreply@github.com", 182 | "date": "2021-03-18T21:25:59Z" 183 | }, 184 | "message": "Update main.yml", 185 | "tree": { 186 | "sha": "db6ed2f642d069697894727e4eec62f7c7d75c4a", 187 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/trees/db6ed2f642d069697894727e4eec62f7c7d75c4a" 188 | }, 189 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/commits/76499729dcc4d6112989249710649e7221e225dd", 190 | "comment_count": 0, 191 | "verification": { 192 | "verified": true, 193 | "reason": "valid", 194 | "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJgU8VnCRBK7hj4Ov3rIwAAdHIIAGncnbye1B3APlh/gQ7hryvl\nM0SDM0rUpe10R3uwnq4Wyf81MsqgVpXmAfpyoJyLqY8pISW9HthSNjJu2a4DSila\ndTWpQfIbQ09gVhO7JV9JR9kG1cZRPnAle7iPKnVIL4kzo+nGTcLbFnwEQWYygb1R\nirFC1EayqtLeMahqj49vY/vuj0rTf4gacxVS6f0KRGusrKq8I4/rQvU7jWgxc6PS\nRDfNVzceEzo//LNBGn5UdbRPxP1wApVivln/DUXS9vNTSprckqYHfN0ZsYFxgNIz\n52YT+pVYJDU17sIHZ+4tQgxghavf1oMNeEgiO7saOe3E/LwcZ2dbr1MbZdr38gw=\n=fLce\n-----END PGP SIGNATURE-----\n", 195 | "payload": "tree db6ed2f642d069697894727e4eec62f7c7d75c4a\nparent 56b7d23168709b71e09adde795b3a5234effb477\nauthor Federico Grandi 1616102759 +0100\ncommitter GitHub 1616102759 +0100\n\nUpdate main.yml" 196 | } 197 | }, 198 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/76499729dcc4d6112989249710649e7221e225dd", 199 | "html_url": "https://github.com/EndBug/temp-action-test/commit/76499729dcc4d6112989249710649e7221e225dd", 200 | "comments_url": "https://api.github.com/repos/EndBug/temp-action-test/commits/76499729dcc4d6112989249710649e7221e225dd/comments", 201 | "author": { 202 | "login": "EndBug", 203 | "id": 26386270, 204 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 205 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 206 | "gravatar_id": "", 207 | "url": "https://api.github.com/users/EndBug", 208 | "html_url": "https://github.com/EndBug", 209 | "followers_url": "https://api.github.com/users/EndBug/followers", 210 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 211 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 212 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 213 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 214 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 215 | "repos_url": "https://api.github.com/users/EndBug/repos", 216 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 217 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 218 | "type": "User", 219 | "site_admin": false 220 | }, 221 | "committer": { 222 | "login": "web-flow", 223 | "id": 19864447, 224 | "node_id": "MDQ6VXNlcjE5ODY0NDQ3", 225 | "avatar_url": "https://avatars.githubusercontent.com/u/19864447?v=4", 226 | "gravatar_id": "", 227 | "url": "https://api.github.com/users/web-flow", 228 | "html_url": "https://github.com/web-flow", 229 | "followers_url": "https://api.github.com/users/web-flow/followers", 230 | "following_url": "https://api.github.com/users/web-flow/following{/other_user}", 231 | "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}", 232 | "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}", 233 | "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions", 234 | "organizations_url": "https://api.github.com/users/web-flow/orgs", 235 | "repos_url": "https://api.github.com/users/web-flow/repos", 236 | "events_url": "https://api.github.com/users/web-flow/events{/privacy}", 237 | "received_events_url": "https://api.github.com/users/web-flow/received_events", 238 | "type": "User", 239 | "site_admin": false 240 | }, 241 | "parents": [ 242 | { 243 | "sha": "56b7d23168709b71e09adde795b3a5234effb477", 244 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/56b7d23168709b71e09adde795b3a5234effb477", 245 | "html_url": "https://github.com/EndBug/temp-action-test/commit/56b7d23168709b71e09adde795b3a5234effb477" 246 | } 247 | ] 248 | }, 249 | { 250 | "sha": "c66c50900af6a2dcd25fde33600c50ca4d5a14bd", 251 | "node_id": "MDY6Q29tbWl0MjA5MTA4ODk2OmM2NmM1MDkwMGFmNmEyZGNkMjVmZGUzMzYwMGM1MGNhNGQ1YTE0YmQ=", 252 | "commit": { 253 | "author": { 254 | "name": "Federico Grandi", 255 | "email": "fgrandi30@gmail.com", 256 | "date": "2021-03-18T21:28:47Z" 257 | }, 258 | "committer": { 259 | "name": "Federico Grandi", 260 | "email": "fgrandi30@gmail.com", 261 | "date": "2021-03-18T21:28:47Z" 262 | }, 263 | "message": "uno", 264 | "tree": { 265 | "sha": "7806e602402c6d35aacb1c518aa4bfd8f0778ef5", 266 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/trees/7806e602402c6d35aacb1c518aa4bfd8f0778ef5" 267 | }, 268 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/commits/c66c50900af6a2dcd25fde33600c50ca4d5a14bd", 269 | "comment_count": 0, 270 | "verification": { 271 | "verified": true, 272 | "reason": "valid", 273 | "signature": "-----BEGIN PGP SIGNATURE-----\n\niQJIBAABCAAyFiEEBMyOcY/VjICIS4jcDiM3TGcXdmwFAmBTxhAUHGZncmFuZGkz\nMEBnbWFpbC5jb20ACgkQDiM3TGcXdmxFaQ/+MUDXAsNxoHkZLEFDwR/K0nYE4r2g\nIN1n+qNGEgim0Cw1E6F8aVdTLLKepAokFEdsIBd0qTaOHa2lK/FranUgACJzDD5E\nxIzZipdXRiCRXC0eUethNfsAh109W6Xm2Ei8KIpoRY8V9lbl61Mr2+Qn7LX+qJVt\nsNy45mTh0aDEraaASu5BvDmguQZuzXAGtPsV0GbiuqxSAsyiWUeBeGYlGX9x9OFU\n+wTgsDkCApkfSlYX/fS6iFE2mOi/flb2RZupkIk91mNtbI4nS1LyKllc5hJn/dMU\ndupH+dnJYj3b9ZqYdYYDNiygNu7x1VmYhfpmtAj1dYU7Q2Oj5J5Cnu1uUR44xEmL\ndLpe9iiTZCcyqk0P1xWDwmy5YfWDYVB7TK94aCjmEDfJBGcbqV+weLH/B7CavcO4\nMVlYJCOa8GHGstcWFLucogvcvbR66e1xMysuBzkENE6SYe7adyz2fjz/7sF9G1aL\ndY6751x2Oixorm+8gOuVDY6Dj199G3H54Og1u+r/o1vAEIAsyzJSmS4VQTGtG0Xe\niOUhC3P4e9J7K5eUZ7LzxSDW9PSkAYupfSVpzVxYPgz4qaUED8bLekWL00a1u5SL\ndrHv2K+CS6x97zOif1w48BoL0kh2TP/kd3KKgdmGqnrpGGf81GjaC2ioBlrqTKxO\nD5u/g13AMzD8p5k=\n=x7bY\n-----END PGP SIGNATURE-----", 274 | "payload": "tree 7806e602402c6d35aacb1c518aa4bfd8f0778ef5\nparent 76499729dcc4d6112989249710649e7221e225dd\nauthor Federico Grandi 1616102927 +0100\ncommitter Federico Grandi 1616102927 +0100\n\nuno\n" 275 | } 276 | }, 277 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/c66c50900af6a2dcd25fde33600c50ca4d5a14bd", 278 | "html_url": "https://github.com/EndBug/temp-action-test/commit/c66c50900af6a2dcd25fde33600c50ca4d5a14bd", 279 | "comments_url": "https://api.github.com/repos/EndBug/temp-action-test/commits/c66c50900af6a2dcd25fde33600c50ca4d5a14bd/comments", 280 | "author": { 281 | "login": "EndBug", 282 | "id": 26386270, 283 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 284 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 285 | "gravatar_id": "", 286 | "url": "https://api.github.com/users/EndBug", 287 | "html_url": "https://github.com/EndBug", 288 | "followers_url": "https://api.github.com/users/EndBug/followers", 289 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 290 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 291 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 292 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 293 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 294 | "repos_url": "https://api.github.com/users/EndBug/repos", 295 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 296 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 297 | "type": "User", 298 | "site_admin": false 299 | }, 300 | "committer": { 301 | "login": "EndBug", 302 | "id": 26386270, 303 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 304 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 305 | "gravatar_id": "", 306 | "url": "https://api.github.com/users/EndBug", 307 | "html_url": "https://github.com/EndBug", 308 | "followers_url": "https://api.github.com/users/EndBug/followers", 309 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 310 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 311 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 312 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 313 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 314 | "repos_url": "https://api.github.com/users/EndBug/repos", 315 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 316 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 317 | "type": "User", 318 | "site_admin": false 319 | }, 320 | "parents": [ 321 | { 322 | "sha": "76499729dcc4d6112989249710649e7221e225dd", 323 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/76499729dcc4d6112989249710649e7221e225dd", 324 | "html_url": "https://github.com/EndBug/temp-action-test/commit/76499729dcc4d6112989249710649e7221e225dd" 325 | } 326 | ] 327 | }, 328 | { 329 | "sha": "4f08cba6da02df0b1ccd709c739a15713cb12e71", 330 | "node_id": "MDY6Q29tbWl0MjA5MTA4ODk2OjRmMDhjYmE2ZGEwMmRmMGIxY2NkNzA5YzczOWExNTcxM2NiMTJlNzE=", 331 | "commit": { 332 | "author": { 333 | "name": "Federico Grandi", 334 | "email": "fgrandi30@gmail.com", 335 | "date": "2021-03-18T21:29:01Z" 336 | }, 337 | "committer": { 338 | "name": "Federico Grandi", 339 | "email": "fgrandi30@gmail.com", 340 | "date": "2021-03-18T21:29:01Z" 341 | }, 342 | "message": "due", 343 | "tree": { 344 | "sha": "db6ed2f642d069697894727e4eec62f7c7d75c4a", 345 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/trees/db6ed2f642d069697894727e4eec62f7c7d75c4a" 346 | }, 347 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/commits/4f08cba6da02df0b1ccd709c739a15713cb12e71", 348 | "comment_count": 0, 349 | "verification": { 350 | "verified": true, 351 | "reason": "valid", 352 | "signature": "-----BEGIN PGP SIGNATURE-----\n\niQJIBAABCAAyFiEEBMyOcY/VjICIS4jcDiM3TGcXdmwFAmBTxh0UHGZncmFuZGkz\nMEBnbWFpbC5jb20ACgkQDiM3TGcXdmxaIxAAxn3domimLnsLqeb92GTuz7qVS1vO\n5EVyxY6K1peDbUG9gmHMCB2q1Y3HA8nggfXbfEnmyRg9Rsm+JH2F7lVoIf3V2bCG\nmIeMJo3jrOyTsyscXu0JMGfnaK9RBkR+UxCDGwa3VTFajL1ewy4ax1hyn63kvs5T\nkD3Ts/xe80SBpnZZLG3Q6CSry8gi15ZbP0cSSVX8hmeNNESZ+bbiw8Z62k2TF4gI\noBDFWHJ6ceWN0jGtwoELOXG+pOrtCqlfAmFE/hygXimevIlHkiylqzj3iVuf/9Bc\nhos28mh2vcdhz4448zNGSt/4aWkf+HVDbCth3TnKZqjLSBdkSGB771e1Tffr/qEo\nZGfIVWVMlGDRl9dgEspBoq0UJKk4ISF63c2QldaMDwf64KVlEzsohkuDfHM3Fty3\n2qe6XmNjfy/YkfoWmQFtr/Uvxi0/TGjYLYDf7+WR6gNSumDg2tsB9gLjz+r1Fb1L\nn2pFmAk9BjbAbKrYh9Q+uetXCtJXxUjWTL9GFwuKwuc0EfMv853B1GeCSBJmlg6Q\nvCmRP/x3K3+vpQJ3j8v5Egu0ZMs67bctnk2Z1RBvRDqlZViwAz1A8W3JSwvRZM7f\nZ+xY+Dk8Cu+f6E092dvwEcnR46zBCmx/izeHUm4mG5GozR+z1t5pChjqnII0Klq8\nwFh0QURrGAlgYSA=\n=7kDC\n-----END PGP SIGNATURE-----", 353 | "payload": "tree db6ed2f642d069697894727e4eec62f7c7d75c4a\nparent c66c50900af6a2dcd25fde33600c50ca4d5a14bd\nauthor Federico Grandi 1616102941 +0100\ncommitter Federico Grandi 1616102941 +0100\n\ndue\n" 354 | } 355 | }, 356 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/4f08cba6da02df0b1ccd709c739a15713cb12e71", 357 | "html_url": "https://github.com/EndBug/temp-action-test/commit/4f08cba6da02df0b1ccd709c739a15713cb12e71", 358 | "comments_url": "https://api.github.com/repos/EndBug/temp-action-test/commits/4f08cba6da02df0b1ccd709c739a15713cb12e71/comments", 359 | "author": { 360 | "login": "EndBug", 361 | "id": 26386270, 362 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 363 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 364 | "gravatar_id": "", 365 | "url": "https://api.github.com/users/EndBug", 366 | "html_url": "https://github.com/EndBug", 367 | "followers_url": "https://api.github.com/users/EndBug/followers", 368 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 369 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 370 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 371 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 372 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 373 | "repos_url": "https://api.github.com/users/EndBug/repos", 374 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 375 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 376 | "type": "User", 377 | "site_admin": false 378 | }, 379 | "committer": { 380 | "login": "EndBug", 381 | "id": 26386270, 382 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 383 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 384 | "gravatar_id": "", 385 | "url": "https://api.github.com/users/EndBug", 386 | "html_url": "https://github.com/EndBug", 387 | "followers_url": "https://api.github.com/users/EndBug/followers", 388 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 389 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 390 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 391 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 392 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 393 | "repos_url": "https://api.github.com/users/EndBug/repos", 394 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 395 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 396 | "type": "User", 397 | "site_admin": false 398 | }, 399 | "parents": [ 400 | { 401 | "sha": "c66c50900af6a2dcd25fde33600c50ca4d5a14bd", 402 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/c66c50900af6a2dcd25fde33600c50ca4d5a14bd", 403 | "html_url": "https://github.com/EndBug/temp-action-test/commit/c66c50900af6a2dcd25fde33600c50ca4d5a14bd" 404 | } 405 | ] 406 | }, 407 | { 408 | "sha": "865c7494515801e928142905d4db5eb7a840f30b", 409 | "node_id": "MDY6Q29tbWl0MjA5MTA4ODk2Ojg2NWM3NDk0NTE1ODAxZTkyODE0MjkwNWQ0ZGI1ZWI3YTg0MGYzMGI=", 410 | "commit": { 411 | "author": { 412 | "name": "Federico Grandi", 413 | "email": "fgrandi30@gmail.com", 414 | "date": "2021-03-18T21:29:08Z" 415 | }, 416 | "committer": { 417 | "name": "Federico Grandi", 418 | "email": "fgrandi30@gmail.com", 419 | "date": "2021-03-18T21:29:08Z" 420 | }, 421 | "message": "tre", 422 | "tree": { 423 | "sha": "7806e602402c6d35aacb1c518aa4bfd8f0778ef5", 424 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/trees/7806e602402c6d35aacb1c518aa4bfd8f0778ef5" 425 | }, 426 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/commits/865c7494515801e928142905d4db5eb7a840f30b", 427 | "comment_count": 0, 428 | "verification": { 429 | "verified": true, 430 | "reason": "valid", 431 | "signature": "-----BEGIN PGP SIGNATURE-----\n\niQJIBAABCAAyFiEEBMyOcY/VjICIS4jcDiM3TGcXdmwFAmBTxiQUHGZncmFuZGkz\nMEBnbWFpbC5jb20ACgkQDiM3TGcXdmx+PxAAuuwb/C/s/1FQvkB+qItRrmUWq3s3\nuDjVSU8Enk/YTv4+xsSACJNnJv9F7OSU9wjzMGoQplTzRSbP9bU4VMB1M/YoHb8X\nvbXETXrzgQgEoq3elMRxlUW5ixgExtcU1VB3rYeQTKeHVtPwAFHnpTNspdeWTJGC\nJgKq1KD6QWL4eS9GbIsUIWRmehmG9Udsv7m56sYXbyQCY8iUHayfh41R0VyUFhrQ\npGoIfgik+9lZSOegyEtP1HmOlPX7ZbWJNkWoL51kH7a333s/JcmVbVu7reknXUCv\nBsBPt8IJApcFx/rnppdPJGBSN8o0hTFzhYlgjsyAikYhslU7F9JbSTN2+O9lCRwe\ne5FWZOY7wnspzDz7H2GxPJGr5ve9PXpGI0IA1k8PB2xPNk7ZYhULlWWUbJvBKYX5\ngL7RzYX2Sv0V3w+fRnMQF7LA+kDdON2Gykne3RlIeYEMDDHqNb18WQfw/p4df9d0\n2lNr534Vk2RoIz/W/0PXIkNcNXEFxRXR9SiwLtmfBCdjhFF3F14QDK5V4LGov8Is\n7OuRyWeWEjU2nITa/HbqDHdJVdHpK7UaJWqi2+Nb1NmVng995323U2QZBKDf+/UX\n2vHb1TvA1DNlX4j/shilqvy9U6SmU/EUZ0+sKMiwDeBmlx89AbO+FQI2LWx4D9Jf\nuI7LLCowPY4CmyM=\n=KlpC\n-----END PGP SIGNATURE-----", 432 | "payload": "tree 7806e602402c6d35aacb1c518aa4bfd8f0778ef5\nparent 4f08cba6da02df0b1ccd709c739a15713cb12e71\nauthor Federico Grandi 1616102948 +0100\ncommitter Federico Grandi 1616102948 +0100\n\ntre\n" 433 | } 434 | }, 435 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/865c7494515801e928142905d4db5eb7a840f30b", 436 | "html_url": "https://github.com/EndBug/temp-action-test/commit/865c7494515801e928142905d4db5eb7a840f30b", 437 | "comments_url": "https://api.github.com/repos/EndBug/temp-action-test/commits/865c7494515801e928142905d4db5eb7a840f30b/comments", 438 | "author": { 439 | "login": "EndBug", 440 | "id": 26386270, 441 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 442 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 443 | "gravatar_id": "", 444 | "url": "https://api.github.com/users/EndBug", 445 | "html_url": "https://github.com/EndBug", 446 | "followers_url": "https://api.github.com/users/EndBug/followers", 447 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 448 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 449 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 450 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 451 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 452 | "repos_url": "https://api.github.com/users/EndBug/repos", 453 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 454 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 455 | "type": "User", 456 | "site_admin": false 457 | }, 458 | "committer": { 459 | "login": "EndBug", 460 | "id": 26386270, 461 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 462 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 463 | "gravatar_id": "", 464 | "url": "https://api.github.com/users/EndBug", 465 | "html_url": "https://github.com/EndBug", 466 | "followers_url": "https://api.github.com/users/EndBug/followers", 467 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 468 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 469 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 470 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 471 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 472 | "repos_url": "https://api.github.com/users/EndBug/repos", 473 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 474 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 475 | "type": "User", 476 | "site_admin": false 477 | }, 478 | "parents": [ 479 | { 480 | "sha": "4f08cba6da02df0b1ccd709c739a15713cb12e71", 481 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/4f08cba6da02df0b1ccd709c739a15713cb12e71", 482 | "html_url": "https://github.com/EndBug/temp-action-test/commit/4f08cba6da02df0b1ccd709c739a15713cb12e71" 483 | } 484 | ] 485 | }, 486 | { 487 | "sha": "7a435d44be1182400597e276c652c4cea26c7f00", 488 | "node_id": "MDY6Q29tbWl0MjA5MTA4ODk2OjdhNDM1ZDQ0YmUxMTgyNDAwNTk3ZTI3NmM2NTJjNGNlYTI2YzdmMDA=", 489 | "commit": { 490 | "author": { 491 | "name": "Federico Grandi", 492 | "email": "fgrandi30@gmail.com", 493 | "date": "2021-03-18T21:29:21Z" 494 | }, 495 | "committer": { 496 | "name": "Federico Grandi", 497 | "email": "fgrandi30@gmail.com", 498 | "date": "2021-03-18T21:29:21Z" 499 | }, 500 | "message": "quattro", 501 | "tree": { 502 | "sha": "db6ed2f642d069697894727e4eec62f7c7d75c4a", 503 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/trees/db6ed2f642d069697894727e4eec62f7c7d75c4a" 504 | }, 505 | "url": "https://api.github.com/repos/EndBug/temp-action-test/git/commits/7a435d44be1182400597e276c652c4cea26c7f00", 506 | "comment_count": 0, 507 | "verification": { 508 | "verified": true, 509 | "reason": "valid", 510 | "signature": "-----BEGIN PGP SIGNATURE-----\n\niQJIBAABCAAyFiEEBMyOcY/VjICIS4jcDiM3TGcXdmwFAmBTxjEUHGZncmFuZGkz\nMEBnbWFpbC5jb20ACgkQDiM3TGcXdmzKSg//ZD3fwdLzB7WPWcrdgk6kjjOUUlfs\noKbvRP1Srgq/g9K17MycIRzOjoLazNP3QJ3wJU4/XaXK8SLeD0BLcGwZLoJ24zkC\nY/BH0TLNVPXXowOUhLXbFqNb/76tmDxrGYC57HKyCI0DAvti+LNXR5dB4P0FJsPq\nMmpIO7CoJ/o7U+52CE5pE2FC2wl8CdzYVYvBSckEgw3mcIE7sEnayncyPIVbv6zP\nl9apIoh9YVZJbzIm+HQSAxDw0gQCXNaQMCbGoLd4Pd82eqnYt1bgt0eyIxmVXSix\njasv7jeB86TgRJfTWBgC7k4F8mmxMb11ZcWUrz7S/vGekrnrrN3EPIq3Ioy2J+Ry\n32yl6WTFqpMZ+w0hB4KTMg18Skm7D4HZHazI+khupUmhhL3hZTg6GpWhtDMyDLy4\nHK4nV2VVjQqCV6VtYHTvflN/IVYYIQcxuqcCofH8w+bVZ3GOe30XUOisIkRxV6cT\nwX/V2RzY4z81pzo+wIFQB82O/pPz545pTW8ck1zQuiOORfCGFpuPeCo3bl1y+U3k\nnjcWAcO3gO3u34lv10BzlZLph5hT5Ssf5oHDrJLPEE7f3GJxZEIGf4r6DVV/ZGX5\nE2WRrAvpu+btpDTxqgiRB+a0SbYNLwz8X9YeSfnR3nTeKxtBcE9PYqGav87YVdNl\nTw4Kqie/UdDCjK0=\n=Xz/u\n-----END PGP SIGNATURE-----", 511 | "payload": "tree db6ed2f642d069697894727e4eec62f7c7d75c4a\nparent 865c7494515801e928142905d4db5eb7a840f30b\nauthor Federico Grandi 1616102961 +0100\ncommitter Federico Grandi 1616102961 +0100\n\nquattro\n" 512 | } 513 | }, 514 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/7a435d44be1182400597e276c652c4cea26c7f00", 515 | "html_url": "https://github.com/EndBug/temp-action-test/commit/7a435d44be1182400597e276c652c4cea26c7f00", 516 | "comments_url": "https://api.github.com/repos/EndBug/temp-action-test/commits/7a435d44be1182400597e276c652c4cea26c7f00/comments", 517 | "author": { 518 | "login": "EndBug", 519 | "id": 26386270, 520 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 521 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 522 | "gravatar_id": "", 523 | "url": "https://api.github.com/users/EndBug", 524 | "html_url": "https://github.com/EndBug", 525 | "followers_url": "https://api.github.com/users/EndBug/followers", 526 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 527 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 528 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 529 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 530 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 531 | "repos_url": "https://api.github.com/users/EndBug/repos", 532 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 533 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 534 | "type": "User", 535 | "site_admin": false 536 | }, 537 | "committer": { 538 | "login": "EndBug", 539 | "id": 26386270, 540 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 541 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 542 | "gravatar_id": "", 543 | "url": "https://api.github.com/users/EndBug", 544 | "html_url": "https://github.com/EndBug", 545 | "followers_url": "https://api.github.com/users/EndBug/followers", 546 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 547 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 548 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 549 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 550 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 551 | "repos_url": "https://api.github.com/users/EndBug/repos", 552 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 553 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 554 | "type": "User", 555 | "site_admin": false 556 | }, 557 | "parents": [ 558 | { 559 | "sha": "865c7494515801e928142905d4db5eb7a840f30b", 560 | "url": "https://api.github.com/repos/EndBug/temp-action-test/commits/865c7494515801e928142905d4db5eb7a840f30b", 561 | "html_url": "https://github.com/EndBug/temp-action-test/commit/865c7494515801e928142905d4db5eb7a840f30b" 562 | } 563 | ] 564 | } 565 | ], 566 | "files": [ 567 | { 568 | "sha": "33f325b98128efd31c19aed1a1e3e12e38380d69", 569 | "filename": ".github/workflows/main.yml", 570 | "status": "modified", 571 | "additions": 3, 572 | "deletions": 1, 573 | "changes": 4, 574 | "blob_url": "https://github.com/EndBug/temp-action-test/blob/7a435d44be1182400597e276c652c4cea26c7f00/.github/workflows/main.yml", 575 | "raw_url": "https://github.com/EndBug/temp-action-test/raw/7a435d44be1182400597e276c652c4cea26c7f00/.github/workflows/main.yml", 576 | "contents_url": "https://api.github.com/repos/EndBug/temp-action-test/contents/.github/workflows/main.yml?ref=7a435d44be1182400597e276c652c4cea26c7f00", 577 | "patch": "@@ -6,4 +6,6 @@ jobs:\n runs-on: ubuntu-latest\n \n steps:\n- - run: echo ${{ github }}\n+ - run: echo $TEST\n+ env:\n+ TEST: ${{ toJSON(github) }}" 578 | } 579 | ] 580 | } 581 | -------------------------------------------------------------------------------- /examples/github_context.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "***", 3 | "job": "check", 4 | "ref": "refs/heads/workflow-test", 5 | "sha": "7a435d44be1182400597e276c652c4cea26c7f00", 6 | "repository": "EndBug/temp-action-test", 7 | "repository_owner": "EndBug", 8 | "repositoryUrl": "git://github.com/EndBug/temp-action-test.git", 9 | "run_id": "665975055", 10 | "run_number": "450", 11 | "retention_days": "14", 12 | "actor": "EndBug", 13 | "workflow": "Test", 14 | "head_ref": "", 15 | "base_ref": "", 16 | "event_name": "push", 17 | "event": { 18 | "after": "7a435d44be1182400597e276c652c4cea26c7f00", 19 | "base_ref": null, 20 | "before": "76499729dcc4d6112989249710649e7221e225dd", 21 | "commits": [ 22 | { 23 | "author": { 24 | "email": "fgrandi30@gmail.com", 25 | "name": "Federico Grandi", 26 | "username": "EndBug" 27 | }, 28 | "committer": { 29 | "email": "fgrandi30@gmail.com", 30 | "name": "Federico Grandi", 31 | "username": "EndBug" 32 | }, 33 | "distinct": true, 34 | "id": "c66c50900af6a2dcd25fde33600c50ca4d5a14bd", 35 | "message": "uno", 36 | "timestamp": "2021-03-18T22:28:47+01:00", 37 | "tree_id": "7806e602402c6d35aacb1c518aa4bfd8f0778ef5", 38 | "url": "https://github.com/EndBug/temp-action-test/commit/c66c50900af6a2dcd25fde33600c50ca4d5a14bd" 39 | }, 40 | { 41 | "author": { 42 | "email": "fgrandi30@gmail.com", 43 | "name": "Federico Grandi", 44 | "username": "EndBug" 45 | }, 46 | "committer": { 47 | "email": "fgrandi30@gmail.com", 48 | "name": "Federico Grandi", 49 | "username": "EndBug" 50 | }, 51 | "distinct": true, 52 | "id": "4f08cba6da02df0b1ccd709c739a15713cb12e71", 53 | "message": "due", 54 | "timestamp": "2021-03-18T22:29:01+01:00", 55 | "tree_id": "db6ed2f642d069697894727e4eec62f7c7d75c4a", 56 | "url": "https://github.com/EndBug/temp-action-test/commit/4f08cba6da02df0b1ccd709c739a15713cb12e71" 57 | }, 58 | { 59 | "author": { 60 | "email": "fgrandi30@gmail.com", 61 | "name": "Federico Grandi", 62 | "username": "EndBug" 63 | }, 64 | "committer": { 65 | "email": "fgrandi30@gmail.com", 66 | "name": "Federico Grandi", 67 | "username": "EndBug" 68 | }, 69 | "distinct": true, 70 | "id": "865c7494515801e928142905d4db5eb7a840f30b", 71 | "message": "tre", 72 | "timestamp": "2021-03-18T22:29:08+01:00", 73 | "tree_id": "7806e602402c6d35aacb1c518aa4bfd8f0778ef5", 74 | "url": "https://github.com/EndBug/temp-action-test/commit/865c7494515801e928142905d4db5eb7a840f30b" 75 | }, 76 | { 77 | "author": { 78 | "email": "fgrandi30@gmail.com", 79 | "name": "Federico Grandi", 80 | "username": "EndBug" 81 | }, 82 | "committer": { 83 | "email": "fgrandi30@gmail.com", 84 | "name": "Federico Grandi", 85 | "username": "EndBug" 86 | }, 87 | "distinct": true, 88 | "id": "7a435d44be1182400597e276c652c4cea26c7f00", 89 | "message": "quattro", 90 | "timestamp": "2021-03-18T22:29:21+01:00", 91 | "tree_id": "db6ed2f642d069697894727e4eec62f7c7d75c4a", 92 | "url": "https://github.com/EndBug/temp-action-test/commit/7a435d44be1182400597e276c652c4cea26c7f00" 93 | } 94 | ], 95 | "compare": "https://github.com/EndBug/temp-action-test/compare/76499729dcc4...7a435d44be11", 96 | "created": false, 97 | "deleted": false, 98 | "forced": false, 99 | "head_commit": { 100 | "author": { 101 | "email": "fgrandi30@gmail.com", 102 | "name": "Federico Grandi", 103 | "username": "EndBug" 104 | }, 105 | "committer": { 106 | "email": "fgrandi30@gmail.com", 107 | "name": "Federico Grandi", 108 | "username": "EndBug" 109 | }, 110 | "distinct": true, 111 | "id": "7a435d44be1182400597e276c652c4cea26c7f00", 112 | "message": "quattro", 113 | "timestamp": "2021-03-18T22:29:21+01:00", 114 | "tree_id": "db6ed2f642d069697894727e4eec62f7c7d75c4a", 115 | "url": "https://github.com/EndBug/temp-action-test/commit/7a435d44be1182400597e276c652c4cea26c7f00" 116 | }, 117 | "pusher": { "email": "fgrandi30@gmail.com", "name": "EndBug" }, 118 | "ref": "refs/heads/workflow-test", 119 | "repository": { 120 | "archive_url": "https://api.github.com/repos/EndBug/temp-action-test/{archive_format}{/ref}", 121 | "archived": false, 122 | "assignees_url": "https://api.github.com/repos/EndBug/temp-action-test/assignees{/user}", 123 | "blobs_url": "https://api.github.com/repos/EndBug/temp-action-test/git/blobs{/sha}", 124 | "branches_url": "https://api.github.com/repos/EndBug/temp-action-test/branches{/branch}", 125 | "clone_url": "https://github.com/EndBug/temp-action-test.git", 126 | "collaborators_url": "https://api.github.com/repos/EndBug/temp-action-test/collaborators{/collaborator}", 127 | "comments_url": "https://api.github.com/repos/EndBug/temp-action-test/comments{/number}", 128 | "commits_url": "https://api.github.com/repos/EndBug/temp-action-test/commits{/sha}", 129 | "compare_url": "https://api.github.com/repos/EndBug/temp-action-test/compare/{base}...{head}", 130 | "contents_url": "https://api.github.com/repos/EndBug/temp-action-test/contents/{+path}", 131 | "contributors_url": "https://api.github.com/repos/EndBug/temp-action-test/contributors", 132 | "created_at": 1568739143, 133 | "default_branch": "master", 134 | "deployments_url": "https://api.github.com/repos/EndBug/temp-action-test/deployments", 135 | "description": null, 136 | "disabled": false, 137 | "downloads_url": "https://api.github.com/repos/EndBug/temp-action-test/downloads", 138 | "events_url": "https://api.github.com/repos/EndBug/temp-action-test/events", 139 | "fork": false, 140 | "forks": 0, 141 | "forks_count": 0, 142 | "forks_url": "https://api.github.com/repos/EndBug/temp-action-test/forks", 143 | "full_name": "EndBug/temp-action-test", 144 | "git_commits_url": "https://api.github.com/repos/EndBug/temp-action-test/git/commits{/sha}", 145 | "git_refs_url": "https://api.github.com/repos/EndBug/temp-action-test/git/refs{/sha}", 146 | "git_tags_url": "https://api.github.com/repos/EndBug/temp-action-test/git/tags{/sha}", 147 | "git_url": "git://github.com/EndBug/temp-action-test.git", 148 | "has_downloads": true, 149 | "has_issues": true, 150 | "has_pages": false, 151 | "has_projects": true, 152 | "has_wiki": true, 153 | "homepage": null, 154 | "hooks_url": "https://api.github.com/repos/EndBug/temp-action-test/hooks", 155 | "html_url": "https://github.com/EndBug/temp-action-test", 156 | "id": 209108896, 157 | "issue_comment_url": "https://api.github.com/repos/EndBug/temp-action-test/issues/comments{/number}", 158 | "issue_events_url": "https://api.github.com/repos/EndBug/temp-action-test/issues/events{/number}", 159 | "issues_url": "https://api.github.com/repos/EndBug/temp-action-test/issues{/number}", 160 | "keys_url": "https://api.github.com/repos/EndBug/temp-action-test/keys{/key_id}", 161 | "labels_url": "https://api.github.com/repos/EndBug/temp-action-test/labels{/name}", 162 | "language": null, 163 | "languages_url": "https://api.github.com/repos/EndBug/temp-action-test/languages", 164 | "license": { 165 | "key": "mit", 166 | "name": "MIT License", 167 | "node_id": "MDc6TGljZW5zZTEz", 168 | "spdx_id": "MIT", 169 | "url": "https://api.github.com/licenses/mit" 170 | }, 171 | "master_branch": "master", 172 | "merges_url": "https://api.github.com/repos/EndBug/temp-action-test/merges", 173 | "milestones_url": "https://api.github.com/repos/EndBug/temp-action-test/milestones{/number}", 174 | "mirror_url": null, 175 | "name": "temp-action-test", 176 | "node_id": "MDEwOlJlcG9zaXRvcnkyMDkxMDg4OTY=", 177 | "notifications_url": "https://api.github.com/repos/EndBug/temp-action-test/notifications{?since,all,participating}", 178 | "open_issues": 0, 179 | "open_issues_count": 0, 180 | "owner": { 181 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 182 | "email": "fgrandi30@gmail.com", 183 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 184 | "followers_url": "https://api.github.com/users/EndBug/followers", 185 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 186 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 187 | "gravatar_id": "", 188 | "html_url": "https://github.com/EndBug", 189 | "id": 26386270, 190 | "login": "EndBug", 191 | "name": "EndBug", 192 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 193 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 194 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 195 | "repos_url": "https://api.github.com/users/EndBug/repos", 196 | "site_admin": false, 197 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 198 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 199 | "type": "User", 200 | "url": "https://api.github.com/users/EndBug" 201 | }, 202 | "private": false, 203 | "pulls_url": "https://api.github.com/repos/EndBug/temp-action-test/pulls{/number}", 204 | "pushed_at": 1616102967, 205 | "releases_url": "https://api.github.com/repos/EndBug/temp-action-test/releases{/id}", 206 | "size": 438, 207 | "ssh_url": "git@github.com:EndBug/temp-action-test.git", 208 | "stargazers": 0, 209 | "stargazers_count": 0, 210 | "stargazers_url": "https://api.github.com/repos/EndBug/temp-action-test/stargazers", 211 | "statuses_url": "https://api.github.com/repos/EndBug/temp-action-test/statuses/{sha}", 212 | "subscribers_url": "https://api.github.com/repos/EndBug/temp-action-test/subscribers", 213 | "subscription_url": "https://api.github.com/repos/EndBug/temp-action-test/subscription", 214 | "svn_url": "https://github.com/EndBug/temp-action-test", 215 | "tags_url": "https://api.github.com/repos/EndBug/temp-action-test/tags", 216 | "teams_url": "https://api.github.com/repos/EndBug/temp-action-test/teams", 217 | "trees_url": "https://api.github.com/repos/EndBug/temp-action-test/git/trees{/sha}", 218 | "updated_at": "2021-01-16T13:37:25Z", 219 | "url": "https://github.com/EndBug/temp-action-test", 220 | "watchers": 0, 221 | "watchers_count": 0 222 | }, 223 | "sender": { 224 | "avatar_url": "https://avatars.githubusercontent.com/u/26386270?v=4", 225 | "events_url": "https://api.github.com/users/EndBug/events{/privacy}", 226 | "followers_url": "https://api.github.com/users/EndBug/followers", 227 | "following_url": "https://api.github.com/users/EndBug/following{/other_user}", 228 | "gists_url": "https://api.github.com/users/EndBug/gists{/gist_id}", 229 | "gravatar_id": "", 230 | "html_url": "https://github.com/EndBug", 231 | "id": 26386270, 232 | "login": "EndBug", 233 | "node_id": "MDQ6VXNlcjI2Mzg2Mjcw", 234 | "organizations_url": "https://api.github.com/users/EndBug/orgs", 235 | "received_events_url": "https://api.github.com/users/EndBug/received_events", 236 | "repos_url": "https://api.github.com/users/EndBug/repos", 237 | "site_admin": false, 238 | "starred_url": "https://api.github.com/users/EndBug/starred{/owner}{/repo}", 239 | "subscriptions_url": "https://api.github.com/users/EndBug/subscriptions", 240 | "type": "User", 241 | "url": "https://api.github.com/users/EndBug" 242 | } 243 | }, 244 | "server_url": "https://github.com", 245 | "api_url": "https://api.github.com", 246 | "graphql_url": "https://api.github.com/graphql", 247 | "workspace": "/home/runner/work/temp-action-test/temp-action-test", 248 | "action": "run" 249 | } 250 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "version-check", 3 | "version": "2.1.5", 4 | "description": "An action that allows you to check whether your npm package version has been updated", 5 | "main": "lib/main.js", 6 | "scripts": { 7 | "build": "ncc build src/main.ts --minify --out lib", 8 | "watch": "ncc build src/main.ts --watch --out lib", 9 | "lint": "eslint ./src --ext ts && echo 'Lint complete.'", 10 | "lint:fix": "eslint ./src --ext ts --fix && echo \"Lint & fix complete.\"", 11 | "prepare": "husky", 12 | "test": "echo \"Error: no test specified\" && exit 1" 13 | }, 14 | "dependencies": { 15 | "@actions/core": "^1.10.1", 16 | "got": "^11.8.3", 17 | "semver-diff": "^4.0.0" 18 | }, 19 | "devDependencies": { 20 | "@types/node": "^20.11.6", 21 | "@typescript-eslint/eslint-plugin": "^6.21.0", 22 | "@typescript-eslint/parser": "^6.20.0", 23 | "@vercel/ncc": "^0.38.2", 24 | "all-contributors-cli": "^6.26.1", 25 | "eslint": "^8.45.0", 26 | "eslint-config-prettier": "^9.1.0", 27 | "eslint-plugin-prettier": "^5.2.1", 28 | "husky": "^9.1.6", 29 | "prettier": "^3.3.3", 30 | "typescript": "^5.4.5" 31 | }, 32 | "repository": { 33 | "type": "git", 34 | "url": "git+https://github.com/EndBug/version-check.git" 35 | }, 36 | "keywords": [ 37 | "github", 38 | "action", 39 | "version", 40 | "npm", 41 | "node" 42 | ], 43 | "author": "Federico Grandi ", 44 | "license": "MIT", 45 | "bugs": { 46 | "url": "https://github.com/EndBug/version-check/issues" 47 | }, 48 | "homepage": "https://github.com/EndBug/version-check#readme", 49 | "engines": { 50 | "node": ">=20" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { 2 | getInput, 3 | getBooleanInput, 4 | setFailed, 5 | info, 6 | error, 7 | warning, 8 | setOutput, 9 | startGroup, 10 | endGroup 11 | } from '@actions/core' 12 | import got from 'got' 13 | import { readFileSync } from 'fs' 14 | import { join, normalize } from 'path' 15 | import semverDiff from 'semver-diff' 16 | 17 | const semverRE = 18 | /^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ 19 | 20 | const semverReGlobal = 21 | /(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?/gm 22 | 23 | const packageFileName = normalize(getInput('file-name') || 'package.json'), 24 | dir = process.env.GITHUB_WORKSPACE || '/github/workspace', 25 | eventFile = process.env.GITHUB_EVENT_PATH || '/github/workflow/event.json', 26 | assumeSameVersion = getInput('assume-same-version') as 27 | | 'old' 28 | | 'new' 29 | | undefined, 30 | staticChecking = getInput('static-checking') as 31 | | 'localIsNew' 32 | | 'remoteIsNew' 33 | | undefined, 34 | token = getInput('token') 35 | 36 | let packageFileURL = (getInput('file-url') || '').trim() 37 | const allowedTags = ['::before'] 38 | 39 | type outputKey = 'changed' | 'type' | 'version' | 'commit' 40 | const outputs: Partial> = {} 41 | 42 | // #region Functions 43 | async function main() { 44 | if ( 45 | packageFileURL && 46 | !isURL(packageFileURL) && 47 | !allowedTags.includes(packageFileURL) 48 | ) 49 | return setFailed( 50 | `The provided package file URL is not valid (received: ${packageFileURL})` 51 | ) 52 | if (assumeSameVersion && !['old', 'new'].includes(assumeSameVersion)) 53 | return setFailed( 54 | `The provided assume-same-version parameter is not valid (received ${assumeSameVersion})` 55 | ) 56 | if (staticChecking && !['localIsNew', 'remoteIsNew'].includes(staticChecking)) 57 | return setFailed( 58 | `The provided static-checking parameter is not valid (received ${staticChecking})` 59 | ) 60 | 61 | const isPackageFileURLBefore = packageFileURL === '::before' 62 | 63 | if (isPackageFileURLBefore) { 64 | const event = await readJson(eventFile) 65 | if (!event) throw new Error(`Can't find event file (${eventFile})`) 66 | 67 | const { before, repository } = event 68 | if (before && repository) { 69 | packageFileURL = `https://raw.githubusercontent.com/${repository?.full_name}/${before}/${packageFileName}` 70 | startGroup('URL tag resolution...') 71 | info( 72 | `::before tag resolved to ${repository?.full_name}/${String( 73 | before 74 | ).substr(0, 7)}/${packageFileName}` 75 | ) 76 | info(`Current package file URL: ${packageFileURL}`) 77 | info(`Using token for remote url: ${!!token}`) 78 | endGroup() 79 | } else 80 | throw new Error( 81 | `Can't correctly read event file (before: ${before}, repository: ${repository})` 82 | ) 83 | } 84 | 85 | if (staticChecking) { 86 | if (!packageFileURL) 87 | return setFailed( 88 | 'Static checking cannot be performed without a `file-url` argument.' 89 | ) 90 | 91 | startGroup('Static-checking files...') 92 | info(`Package file name: "${packageFileName}"`) 93 | info(`Package file URL: "${packageFileURL}"`) 94 | const local: string = (await readJson(join(dir, packageFileName)))?.version, 95 | remote: string = ( 96 | await readJson( 97 | packageFileURL, 98 | (isPackageFileURLBefore || isRawGithubUrl(packageFileURL)) && token 99 | ? token 100 | : undefined 101 | ) 102 | )?.version 103 | if (!local || !remote) { 104 | endGroup() 105 | return setFailed(`Couldn't find ${local ? 'local' : 'remote'} version.`) 106 | } 107 | 108 | if (!semverRE.test(local)) { 109 | return setFailed(`Local version does not match semver pattern`) 110 | } 111 | 112 | if (!semverRE.test(remote)) { 113 | return setFailed(`Remote version does not match semver pattern`) 114 | } 115 | 116 | const versionDiff = 117 | staticChecking === 'localIsNew' 118 | ? semverDiff(remote, local) 119 | : semverDiff(local, remote) 120 | 121 | if (versionDiff) { 122 | output('changed', true) 123 | output('version', staticChecking == 'localIsNew' ? local : remote) 124 | output('type', versionDiff) 125 | 126 | endGroup() 127 | info( 128 | `Found match for version ${ 129 | staticChecking == 'localIsNew' ? local : remote 130 | }` 131 | ) 132 | } 133 | } else { 134 | const eventObj = await readJson(eventFile) 135 | const commits = 136 | eventObj.commits || 137 | (await request(eventObj.pull_request._links.commits.href)) 138 | await processDirectory(dir, commits) 139 | } 140 | } 141 | 142 | function isURL(str: string) { 143 | try { 144 | new URL(str) 145 | return true 146 | } catch { 147 | return false 148 | } 149 | } 150 | 151 | function isRawGithubUrl(str: string) { 152 | const url = new URL(str) 153 | return url.hostname === 'raw.githubusercontent.com' 154 | } 155 | 156 | async function readJson(file: string, token?: string) { 157 | if (isURL(file)) { 158 | const headers = token 159 | ? { 160 | Authorization: `token ${token}` 161 | } 162 | : {} 163 | return ( 164 | await got({ 165 | url: file, 166 | method: 'GET', 167 | headers, 168 | responseType: 'json' 169 | }) 170 | ).body 171 | } else { 172 | const data = readFileSync(file, { encoding: 'utf8' }) 173 | if (typeof data == 'string') 174 | try { 175 | return JSON.parse(data) 176 | } catch (e) { 177 | error(e instanceof Error ? e.stack || e.message : e + '') 178 | } 179 | } 180 | } 181 | 182 | async function request(url: string) { 183 | const headers = token 184 | ? { 185 | Authorization: `Bearer ${token}` 186 | } 187 | : {} 188 | return ( 189 | await got({ 190 | url, 191 | method: 'GET', 192 | headers, 193 | responseType: 'json' 194 | }) 195 | ).body 196 | } 197 | 198 | async function processDirectory( 199 | dir: string, 200 | commits: LocalCommit[] | PartialCommitResponse[] 201 | ) { 202 | try { 203 | const packageObj = await ( 204 | packageFileURL 205 | ? readJson(packageFileURL) 206 | : readJson(join(dir, packageFileName)) 207 | ).catch(() => { 208 | Promise.reject( 209 | new NeutralExitError(`Package file not found: ${packageFileName}`) 210 | ) 211 | }) 212 | 213 | if (!isPackageObj(packageObj)) throw new Error("Can't find version field") 214 | 215 | if (commits.length >= 20) 216 | warning( 217 | 'This workflow run topped the commit limit set by GitHub webhooks: that means that commits could not appear and that the run could not find the version change.' 218 | ) 219 | 220 | if (commits.length <= 0) { 221 | info('There are no commits to look at.') 222 | return 223 | } 224 | 225 | await checkCommits(commits, packageObj.version) 226 | } catch (e) { 227 | setFailed(`${e}`) 228 | } 229 | } 230 | 231 | async function checkCommits( 232 | commits: LocalCommit[] | PartialCommitResponse[], 233 | version: string 234 | ) { 235 | try { 236 | startGroup( 237 | `Searching in ${commits.length} commit${ 238 | commits.length == 1 ? '' : 's' 239 | }...` 240 | ) 241 | info(`Package file name: "${packageFileName}"`) 242 | info( 243 | `Package file URL: ${ 244 | packageFileURL ? `"${packageFileURL}"` : 'undefined' 245 | }` 246 | ) 247 | info( 248 | `Version assumptions: ${ 249 | assumeSameVersion ? `"${assumeSameVersion}"` : 'undefined' 250 | }` 251 | ) 252 | for (const commit of commits) { 253 | const { message, sha } = getBasicInfo(commit) 254 | const match: string[] = message.match(semverReGlobal) || [] 255 | if (match.includes(version)) { 256 | if (await checkDiff(sha, version)) { 257 | endGroup() 258 | info( 259 | `Found match for version ${version}: ${sha.substring( 260 | 0, 261 | 7 262 | )} ${message}` 263 | ) 264 | return true 265 | } 266 | } 267 | } 268 | endGroup() 269 | 270 | if (getBooleanInput('diff-search')) { 271 | info( 272 | 'No standard npm version commit found, switching to diff search (this could take more time...)' 273 | ) 274 | 275 | if (!isLocalCommitArray(commits)) { 276 | commits = commits.sort( 277 | (a, b) => 278 | new Date(b.commit.committer.date).getTime() - 279 | new Date(a.commit.committer.date).getTime() 280 | ) 281 | } 282 | 283 | startGroup( 284 | `Checking the diffs of ${commits.length} commit${ 285 | commits.length == 1 ? '' : 's' 286 | }...` 287 | ) 288 | for (const commit of commits) { 289 | const { message, sha } = getBasicInfo(commit) 290 | 291 | if (await checkDiff(sha, version)) { 292 | endGroup() 293 | info( 294 | `Found match for version ${version}: ${sha.substring( 295 | 0, 296 | 7 297 | )} - ${message}` 298 | ) 299 | return true 300 | } 301 | } 302 | } 303 | 304 | endGroup() 305 | info('No matching commit found.') 306 | output('changed', false) 307 | return false 308 | } catch (e) { 309 | setFailed(`${e}`) 310 | } 311 | } 312 | 313 | function getBasicInfo(commit: LocalCommit | PartialCommitResponse) { 314 | let message: string, sha: string 315 | 316 | if (isLocalCommit(commit)) { 317 | message = commit.message 318 | sha = commit.id 319 | } else { 320 | message = commit.commit.message 321 | sha = commit.sha 322 | } 323 | 324 | return { 325 | message, 326 | sha 327 | } 328 | } 329 | 330 | async function checkDiff(sha: string, version: string) { 331 | try { 332 | const commit = await getCommit(sha) 333 | const pkg = commit.files.find((f) => f.filename == packageFileName) 334 | if (!pkg) { 335 | info(`- ${sha.substr(0, 7)}: no changes to the package file`) 336 | return false 337 | } 338 | 339 | const versionLines: { 340 | added?: string 341 | deleted?: string 342 | } = {} 343 | 344 | const rawLines = pkg.patch 345 | .split('\n') 346 | .filter( 347 | (line) => line.includes('"version":') && ['+', '-'].includes(line[0]) 348 | ) 349 | if (rawLines.length > 2) { 350 | info(`- ${sha.substr(0, 7)}: too many version lines`) 351 | return false 352 | } 353 | 354 | for (const line of rawLines) 355 | versionLines[line.startsWith('+') ? 'added' : 'deleted'] = line 356 | if (!versionLines.added) { 357 | info(`- ${sha.substr(0, 7)}: no "+ version" line`) 358 | return false 359 | } 360 | 361 | const versions = { 362 | added: 363 | assumeSameVersion == 'new' 364 | ? version 365 | : parseVersionLine(versionLines.added), 366 | deleted: 367 | assumeSameVersion == 'old' 368 | ? version 369 | : !!versionLines.deleted && parseVersionLine(versionLines.deleted) 370 | } 371 | if (versions.added != version && !assumeSameVersion) { 372 | info( 373 | `- ${sha.substr( 374 | 0, 375 | 7 376 | )}: added version doesn't match current one (added: "${ 377 | versions.added 378 | }"; current: "${version}")` 379 | ) 380 | return false 381 | } 382 | 383 | output('changed', true) 384 | output('version', version) 385 | if (versions.deleted) 386 | output('type', semverDiff(versions.deleted, versions.added as string)) 387 | output('commit', commit.sha) 388 | 389 | info(`- ${sha.substr(0, 7)}: match found, more info below`) 390 | return true 391 | } catch (e) { 392 | error(`An error occurred in checkDiff:\n${e}`) 393 | throw new ExitError(1) 394 | } 395 | } 396 | 397 | function trimTrailingSlashFromUrl(rawUrl) { 398 | const url = rawUrl.trim() 399 | return url.endsWith('/') ? url.slice(0, -1) : url 400 | } 401 | 402 | async function getCommit(sha: string): Promise { 403 | const githubApiUrl = trimTrailingSlashFromUrl(getInput('github-api-url')) 404 | const url = `${githubApiUrl}/repos/${process.env.GITHUB_REPOSITORY}/commits/${sha}` 405 | const res = await request(url) 406 | 407 | if (typeof res != 'object' || !res) 408 | throw new Error('Response data must be an object.') 409 | 410 | return res as CommitResponse 411 | } 412 | 413 | function parseVersionLine(str: string) { 414 | return (str.split('"') || []).map((s) => matchVersion(s)).find((e) => !!e) 415 | } 416 | 417 | function matchVersion(str: string): string { 418 | return (str.match(semverReGlobal) || ([] as string[]))[0] 419 | } 420 | 421 | function output(name: outputKey, value?: string | boolean) { 422 | outputs[name] = value 423 | return setOutput(name, `${value}`) 424 | } 425 | 426 | function logOutputs() { 427 | startGroup('Outputs:') 428 | for (const key in outputs) { 429 | info(`${key}: ${outputs[key]}`) 430 | } 431 | endGroup() 432 | } 433 | // #endregion 434 | 435 | // #region Error classes 436 | class ExitError extends Error { 437 | code?: number 438 | 439 | constructor(code: number | null) { 440 | super(`Command failed with code ${code}`) 441 | if (typeof code == 'number') this.code = code 442 | } 443 | } 444 | 445 | class NeutralExitError extends Error {} 446 | // #endregion 447 | 448 | if (require.main == module) { 449 | info('Searching for version update...') 450 | main() 451 | .then(() => { 452 | if (typeof outputs.changed == 'undefined') { 453 | output('changed', false) 454 | } 455 | 456 | logOutputs() 457 | }) 458 | .catch((e) => { 459 | if (e instanceof NeutralExitError) process.exitCode = 78 460 | else { 461 | process.exitCode = 1 462 | error(e.message || e) 463 | } 464 | }) 465 | } 466 | 467 | // #region Types and interfaces 468 | interface CommitResponse extends PartialCommitResponse { 469 | files: { 470 | filename: string 471 | additions: number 472 | deletions: number 473 | changes: number 474 | status: string 475 | raw_url: string 476 | blob_url: string 477 | patch: string 478 | }[] 479 | } 480 | 481 | interface LocalCommit { 482 | id: string 483 | message: string 484 | author: { 485 | name: string 486 | email: string 487 | } 488 | url: string 489 | distinct: boolean 490 | } 491 | function isLocalCommit(value): value is LocalCommit { 492 | return typeof value.id == 'string' 493 | } 494 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 495 | function isLocalCommitArray(value: any[]): value is LocalCommit[] { 496 | return isLocalCommit(value[0]) 497 | } 498 | 499 | interface PackageObj { 500 | version: string 501 | } 502 | function isPackageObj(value): value is PackageObj { 503 | return !!value && !!value.version 504 | } 505 | 506 | interface PartialCommitResponse { 507 | url: string 508 | sha: string 509 | node_id: string 510 | html_url: string 511 | comments_url: string 512 | commit: { 513 | url: string 514 | author: { 515 | name: string 516 | email: string 517 | date: string 518 | } 519 | committer: { 520 | name: string 521 | email: string 522 | date: string 523 | } 524 | message: string 525 | tree: { 526 | url: string 527 | sha: string 528 | } 529 | comment_count: number 530 | verification: { 531 | verified: boolean 532 | reason: string 533 | signature: object | null 534 | payload: object | null 535 | } 536 | } 537 | author: { 538 | login: string 539 | id: number 540 | node_id: string 541 | avatar_url: string 542 | gravatar_id: string 543 | url: string 544 | html_url: string 545 | followers_url: string 546 | following_url: string 547 | gists_url: string 548 | starred_url: string 549 | subscriptions_url: string 550 | organizations_url: string 551 | repos_url: string 552 | events_url: string 553 | receive_events_url: string 554 | type: string 555 | site_admin: boolean 556 | } 557 | committer: { 558 | login: string 559 | id: number 560 | node_id: string 561 | avatar_url: string 562 | gravatar_id: string 563 | url: string 564 | html_url: string 565 | followers_url: string 566 | following_url: string 567 | gists_url: string 568 | starred_url: string 569 | subscriptions_url: string 570 | organizations_url: string 571 | repos_url: string 572 | events_url: string 573 | receive_events_url: string 574 | type: string 575 | site_admin: boolean 576 | } 577 | parents: { 578 | url: string 579 | sha: string 580 | }[] 581 | stats: { 582 | additions: number 583 | deletions: number 584 | total: number 585 | } 586 | } 587 | // #endregion 588 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | // "incremental": true, /* Enable incremental compilation */ 5 | "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ 6 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 7 | // "allowJs": true, /* Allow javascript files to be compiled. */ 8 | // "checkJs": true, /* Report errors in .js files. */ 9 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 10 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 11 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 12 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 13 | // "outFile": "./", /* Concatenate and emit output to single file. */ 14 | "outDir": "./build", /* Redirect output structure to the directory. */ 15 | "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 16 | // "composite": true, /* Enable project compilation */ 17 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 18 | // "removeComments": true, /* Do not emit comments to output. */ 19 | // "noEmit": true, /* Do not emit outputs. */ 20 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 21 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 22 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 23 | /* Strict Type-Checking Options */ 24 | "strict": true, /* Enable all strict type-checking options. */ 25 | "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */ 26 | // "strictNullChecks": true, /* Enable strict null checks. */ 27 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 28 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 29 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 30 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 31 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 32 | /* Additional Checks */ 33 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 34 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 35 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 36 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 37 | /* Module Resolution Options */ 38 | "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 39 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 40 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 41 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 42 | // "typeRoots": [], /* List of folders to include type definitions from. */ 43 | // "types": [], /* Type declaration files to be included in compilation. */ 44 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 45 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 46 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 47 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 48 | /* Source Map Options */ 49 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 50 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 51 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 52 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 53 | /* Experimental Options */ 54 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 55 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 56 | }, 57 | "exclude": [ 58 | "node_modules", 59 | "**/*.test.ts" 60 | ] 61 | } 62 | --------------------------------------------------------------------------------