93 Commits
2.2.1 ... 2.6.0

Author SHA1 Message Date
Sven-Hendrik Haase
58d5258088 2.6.0 2023-05-23 22:33:22 +02:00
Sven-Hendrik Haase
ffc1afa9c0 Update CHANGELOG 2023-05-23 22:31:32 +02:00
Sven-Hendrik Haase
24bced81d9 Merge pull request #74 from regevbr/body
feature - promote prerelease
2023-05-23 22:30:22 +02:00
regevbr
794b3152e1 fix #42 - overwrite body and name as well 2023-05-23 22:55:20 +03:00
regevbr
b00963776a fix #42 - overwrite body and name as well 2023-05-23 22:54:48 +03:00
regevbr
210500d479 fix #42 - overwrite body and name as well 2023-05-23 09:49:27 +03:00
Sven-Hendrik Haase
f0dfba8919 Update CHANGELOG for overwrite fixes 2023-05-23 03:52:28 +02:00
Sven-Hendrik Haase
42c63808d6 Merge pull request #106 from regevbr/body_update
fix #42 - overwrite body and name as well
2023-05-23 03:49:38 +02:00
regevbr
febd7d0808 fix #42 - overwrite body and name as well 2023-05-22 23:52:51 +03:00
Sven-Hendrik Haase
d8e2a64134 Merge pull request #105 from svenstaro/bump-deps
Bump deps
2023-05-22 22:29:47 +02:00
Sven-Hendrik Haase
a4af572b12 Bump deps 2023-05-22 22:14:47 +02:00
Sven-Hendrik Haase
7d4e20c14b Bump deps 2023-05-22 20:54:45 +02:00
Sven-Hendrik Haase
7e467024cd Merge pull request #104 from regevbr/ci_fix
fix - fix ci
2023-05-22 20:50:04 +02:00
regevbr
e225e77501 fix - fix ci 2023-05-22 21:29:20 +03:00
Sven-Hendrik Haase
6295ff030e Update CHANGELOG 2023-05-22 02:19:26 +02:00
Sven-Hendrik Haase
37a32b0167 Merge pull request #100 from brandonkelly/make-latest
Add `make_latest` param
2023-05-22 02:15:00 +02:00
Sven-Hendrik Haase
0c6fec2cea Merge pull request #102 from Loyalsoldier/fix-file-empty
Fix: skip uploading empty files
2023-05-22 02:13:13 +02:00
Sven-Hendrik Haase
37f4f3a9cd Merge pull request #103 from Loyalsoldier/fix-lock
Fix: package version in lock file
2023-05-22 02:06:56 +02:00
Loyalsoldier
dfae8c036c Fix: package version in lock file 2023-05-11 14:55:32 +08:00
Loyalsoldier
99e2100a1f Fix: skip uploading empty files 2023-05-11 14:47:45 +08:00
Sven-Hendrik Haase
664a7c20c1 Better README markup 2023-04-27 17:29:08 +02:00
brandonkelly
760a5584dc make_latest param 2023-04-12 17:36:04 -07:00
Sven-Hendrik Haase
580065490f Merge pull request #98 from edgarrmondragon/document-granular-permissions
Document usage with granular permissions
2023-04-11 08:47:18 +02:00
Edgar Ramírez Mondragón
eed453b613 Document usage with granular permissions 2023-04-11 00:05:14 -06:00
Sven-Hendrik Haase
7319e4733e 2.5.0 2023-02-21 15:45:38 +01:00
Sven-Hendrik Haase
4e86b8565b Prepare release 2023-02-21 15:11:15 +01:00
Sven-Hendrik Haase
3a6baf0f12 Add CHANGELOG entry for retry feature 2023-02-21 15:08:59 +01:00
Sven-Hendrik Haase
e8c797e08e Merge pull request #96 from sonphantrung/retry-v2
Add retry to upload release (UPDATED VERSION)
2023-02-21 15:07:45 +01:00
Son Phan Trung
cf83be2c7f Merge branch 'master' into retry-v2 2023-02-21 20:08:09 +07:00
Son Phan Trung
cfdd9b50bd Merge branch 'retry' of https://github.com/messense/upload-release-action 2023-02-21 20:06:34 +07:00
Sven-Hendrik Haase
cc92c9093e 2.4.1 2023-02-01 23:55:13 +01:00
Sven-Hendrik Haase
72f6bf584a Merge pull request #93 from ggreif/gabor/fix
Fix uploading of assets
2023-01-31 22:49:36 +01:00
Gabor Greif
f2899b4677 use createReadStream 2023-01-31 20:27:15 +01:00
Gabor Greif
af306bddfe Revert "use the @file mechanism of octokit-5"
This reverts commit e5e4b800aa.
2023-01-31 20:23:19 +01:00
Sven-Hendrik Haase
9927d3f5ec Merge pull request #92 from ggreif/patch-2
Use the `@file` mechanism of octokit-5
2023-01-31 11:51:05 +01:00
Gabor Greif
e5e4b800aa use the @file mechanism of octokit-5 2023-01-28 22:34:53 +01:00
Sven-Hendrik Haase
74f6bde645 Merge pull request #91 from ggreif/gabor/subst
transform back substituted characters
2023-01-21 10:51:05 +01:00
Gabor Greif
0e6c75888a move percent recovery to the last step 2023-01-20 14:40:32 +01:00
Gabor Greif
5cbce4f5ee do the transpilation 2023-01-20 03:39:20 +01:00
Gabor Greif
df11ebfac2 test % too 2023-01-19 15:19:07 +01:00
Gabor Greif
50a5b0990c also lowercase 2023-01-19 15:15:10 +01:00
Gabor Greif
0e0bd99213 first attemt to transform back substituted characters 2023-01-19 15:07:12 +01:00
Sven-Hendrik Haase
8250434419 Update to newer Octokit 2023-01-19 13:02:09 +01:00
Sven-Hendrik Haase
9093186278 Merge pull request #90 from ggreif/patch-1
Test a two-liner body
2023-01-19 11:42:10 +01:00
Sven-Hendrik Haase
321f000b6d Go back to glob v7
It seems like glob v8 is broken on Windows for some reason.
No time to investigate this now.
2023-01-19 11:39:06 +01:00
Gabor Greif
233ab9a35e bump 2023-01-18 23:43:37 +01:00
Gabor Greif
d3a6c14a79 check for multi-line too 2023-01-18 23:40:07 +01:00
Gabor Greif
fa5d5d5a33 test a two-liner 2023-01-18 23:33:57 +01:00
Sven-Hendrik Haase
442eb645ce Merge pull request #89 from shawaj/patch-1
fix: updated readme to reflect updated version
2023-01-09 10:41:10 +01:00
Aaron Shaw
4d1e10f6d1 Update README.md 2023-01-09 02:24:13 +00:00
Aaron Shaw
f63a22975a Update README.md 2023-01-09 02:13:15 +00:00
Aaron Shaw
a9842f0f62 fix: updated readme to reflect updated version
Relates-to: #85
2023-01-09 02:08:24 +00:00
Sven-Hendrik Haase
2728235f7d 2.4.0 2023-01-09 02:49:49 +01:00
Sven-Hendrik Haase
c2e0608dc4 Merge pull request #88 from svenstaro/dependabot/npm_and_yarn/json5-1.0.2
Bump json5 from 1.0.1 to 1.0.2
2023-01-03 22:48:34 +01:00
Sven-Hendrik Haase
bd74772a1a Don't shadow vars 2023-01-03 22:45:08 +01:00
dependabot[bot]
16e7903b2d Bump json5 from 1.0.1 to 1.0.2
Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-03 21:38:30 +00:00
Sven-Hendrik Haase
f2c549b117 Bump some more deps 2023-01-03 22:31:31 +01:00
Sven-Hendrik Haase
7a7d004438 Bump some deps 2023-01-03 22:27:35 +01:00
Sven-Hendrik Haase
9c4a92ec0d Use explicit any 2023-01-03 22:20:36 +01:00
Sven-Hendrik Haase
039214a996 Bump jest and typescript versions 2023-01-03 22:13:40 +01:00
Sven-Hendrik Haase
2b373356cb Update to node16 2023-01-03 22:09:30 +01:00
messense
1819382cf9 Add retry to upload release 2022-07-03 11:23:10 +08:00
Sven-Hendrik Haase
fb1eb39e74 Merge pull request #75 from svenstaro/dependabot/npm_and_yarn/jsdom-16.7.0
Bump jsdom from 16.4.0 to 16.7.0
2022-06-23 12:06:33 +02:00
dependabot[bot]
7786b24bd8 Bump jsdom from 16.4.0 to 16.7.0
Bumps [jsdom](https://github.com/jsdom/jsdom) from 16.4.0 to 16.7.0.
- [Release notes](https://github.com/jsdom/jsdom/releases)
- [Changelog](https://github.com/jsdom/jsdom/blob/master/Changelog.md)
- [Commits](https://github.com/jsdom/jsdom/compare/16.4.0...16.7.0)

---
updated-dependencies:
- dependency-name: jsdom
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-23 10:01:32 +00:00
Sven-Hendrik Haase
133984371c 2.3.0 2022-06-05 19:04:28 +02:00
Sven-Hendrik Haase
c2b649c57e Merge pull request #72 from svenstaro/dependabot/npm_and_yarn/node-fetch-2.6.7
Bump node-fetch from 2.6.1 to 2.6.7
2022-05-28 07:07:29 +02:00
Sven-Hendrik Haase
eb625cd0ad Merge pull request #71 from svenstaro/dependabot/npm_and_yarn/ansi-regex-4.1.1
Bump ansi-regex from 4.1.0 to 4.1.1
2022-05-28 07:07:19 +02:00
dependabot[bot]
99cbd251b2 Bump node-fetch from 2.6.1 to 2.6.7
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-28 05:05:58 +00:00
dependabot[bot]
a6824c9e54 Bump ansi-regex from 4.1.0 to 4.1.1
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-28 05:05:57 +00:00
Sven-Hendrik Haase
6eb74c809d Merge pull request #67 from svenstaro/dependabot/npm_and_yarn/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6
2022-05-28 07:05:23 +02:00
Sven-Hendrik Haase
8ec375d911 Merge pull request #69 from leighmcculloch/patch-1
Add defaults to commonly set fields to reduce setup
2022-05-28 07:04:25 +02:00
Leigh McCulloch
8d45355ac2 Update README.md 2022-04-04 00:56:40 -07:00
Leigh McCulloch
7d269bd712 Add defaults to commonly set fields to reduce setup 2022-04-04 00:54:54 -07:00
dependabot[bot]
c71fb95114 Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-24 13:12:37 +00:00
Sven-Hendrik Haase
1d71c233f7 Merge pull request #47 from svenstaro/dependabot/npm_and_yarn/y18n-4.0.1
Bump y18n from 4.0.0 to 4.0.1
2021-11-18 06:45:47 +01:00
Sven-Hendrik Haase
78ec101a88 Merge pull request #58 from svenstaro/dependabot/npm_and_yarn/tmpl-1.0.5
Bump tmpl from 1.0.4 to 1.0.5
2021-11-18 06:45:36 +01:00
dependabot[bot]
d8cafc3c87 Bump tmpl from 1.0.4 to 1.0.5
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-21 12:11:16 +00:00
Sven-Hendrik Haase
a70d06e688 Merge pull request #55 from svenstaro/dependabot/npm_and_yarn/path-parse-1.0.7
Bump path-parse from 1.0.6 to 1.0.7
2021-08-24 05:10:49 +02:00
dependabot[bot]
072f986a7c Bump path-parse from 1.0.6 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-11 09:35:24 +00:00
Sven-Hendrik Haase
2f88c7710e Merge pull request #53 from svenstaro/dependabot/npm_and_yarn/glob-parent-5.1.2
Bump glob-parent from 5.1.1 to 5.1.2
2021-06-13 08:08:56 +02:00
dependabot[bot]
ee200cfabc Bump glob-parent from 5.1.1 to 5.1.2
Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 5.1.1 to 5.1.2.
- [Release notes](https://github.com/gulpjs/glob-parent/releases)
- [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md)
- [Commits](https://github.com/gulpjs/glob-parent/compare/v5.1.1...v5.1.2)

---
updated-dependencies:
- dependency-name: glob-parent
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 23:29:23 +00:00
Sven-Hendrik Haase
82b6f4a2ea Merge pull request #52 from svenstaro/dependabot/npm_and_yarn/ws-7.4.6
Bump ws from 7.3.1 to 7.4.6
2021-05-29 19:55:57 +02:00
dependabot[bot]
3f585610ac Bump ws from 7.3.1 to 7.4.6
Bumps [ws](https://github.com/websockets/ws) from 7.3.1 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.3.1...7.4.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-29 13:48:38 +00:00
Sven-Hendrik Haase
61a0748878 Merge pull request #51 from svenstaro/dependabot/npm_and_yarn/hosted-git-info-2.8.9
Bump hosted-git-info from 2.8.8 to 2.8.9
2021-05-10 23:51:40 +02:00
dependabot[bot]
743e8a90bd Bump hosted-git-info from 2.8.8 to 2.8.9
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-10 21:23:58 +00:00
Sven-Hendrik Haase
15ebdecb60 Merge pull request #50 from svenstaro/dependabot/npm_and_yarn/lodash-4.17.21
Bump lodash from 4.17.19 to 4.17.21
2021-05-10 23:23:15 +02:00
dependabot[bot]
57649ec774 Bump lodash from 4.17.19 to 4.17.21
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-10 09:07:37 +00:00
Sven-Hendrik Haase
f9dffdf5a6 Merge pull request #49 from pranjal-joshi/docs-update
Example added for feeding a file to the body tag
2021-05-02 07:48:42 +02:00
Pranjal Joshi
71756ac6ec Example added for feeding a file to the body tag 2021-05-02 10:28:27 +05:30
Pranjal Joshi
2b6c678b07 Example added for feeding file to body tag 2021-05-02 10:24:18 +05:30
dependabot[bot]
a95c4e7c33 Bump y18n from 4.0.0 to 4.0.1
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-30 23:00:12 +00:00
Sven-Hendrik Haase
4e5de20777 Merge pull request #40 from svenstaro/dependabot/npm_and_yarn/node-notifier-8.0.1
Bump node-notifier from 8.0.0 to 8.0.1
2020-12-22 10:40:51 +01:00
dependabot[bot]
3f38d56a41 Bump node-notifier from 8.0.0 to 8.0.1
Bumps [node-notifier](https://github.com/mikaelbr/node-notifier) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/mikaelbr/node-notifier/releases)
- [Changelog](https://github.com/mikaelbr/node-notifier/blob/v8.0.1/CHANGELOG.md)
- [Commits](https://github.com/mikaelbr/node-notifier/compare/v8.0.0...v8.0.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-22 08:20:52 +00:00
10 changed files with 25979 additions and 18136 deletions

View File

@@ -24,7 +24,6 @@
"@typescript-eslint/func-call-spacing": ["error", "never"], "@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error", "@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error", "@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error", "@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error", "@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error", "@typescript-eslint/no-inferrable-types": "error",

View File

@@ -9,7 +9,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- run: | - run: |
npm install npm install
npm run all npm run all
@@ -21,7 +21,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Make test pre-release - name: Make test pre-release
uses: ./ uses: ./
with: with:
@@ -31,26 +31,57 @@ jobs:
tag: ci-test-${{ matrix.os }}-${{ github.run_id }} tag: ci-test-${{ matrix.os }}-${{ github.run_id }}
overwrite: true overwrite: true
prerelease: true prerelease: true
body: "rofl lol test" make_latest: true
body: "rofl lol test%0Aianal %25 fubar"
- name: Check that the uploaded asset is readable - name: Check that the uploaded asset is readable
uses: actions/github-script@v2 uses: actions/github-script@v2
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
const fs = require('fs') const fs = require('fs')
const child_process = require('child_process');
const assert = require('assert').strict; const assert = require('assert').strict;
const expected = fs.readFileSync("README.md") const expected = fs.readFileSync("README.md", "utf-8")
const release = await github.repos.getReleaseByTag({ const release = await github.repos.getReleaseByTag({
...context.repo, ...context.repo,
tag: "ci-test-${{ matrix.os }}-${{ github.run_id }}", tag: "ci-test-${{ matrix.os }}-${{ github.run_id }}",
}) })
assert.deepStrictEqual(release.data.prerelease, true) assert.deepStrictEqual(release.data.prerelease, true)
assert.deepStrictEqual(release.data.body, "rofl lol test") assert.deepStrictEqual(release.data.body, "rofl lol test\nianal % fubar")
assert.deepStrictEqual(release.data.assets[0].name, "TEST.md") assert.deepStrictEqual(release.data.assets[0].name, "TEST.md")
const actual = child_process.execSync(`curl -Ls ${release.data.assets[0].browser_download_url}`) const actual = await github.request(release.data.assets[0].browser_download_url)
assert.deepStrictEqual(expected, actual) assert.deepStrictEqual(expected, actual.data)
- name: Make test promote
uses: ./
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: README.md
asset_name: TEST.md
tag: ci-test-${{ matrix.os }}-${{ github.run_id }}
overwrite: true
promote: true
prerelease: false
make_latest: true
body: "new body"
- name: Check that the release is promoted
uses: actions/github-script@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
retries: 15
script: |
const fs = require('fs')
const assert = require('assert').strict;
const expected = fs.readFileSync("README.md", "utf-8")
const release = await github.repos.getReleaseByTag({
...context.repo,
tag: "ci-test-${{ matrix.os }}-${{ github.run_id }}",
})
assert.deepStrictEqual(release.data.prerelease, false)
assert.deepStrictEqual(release.data.body, "new body")
assert.deepStrictEqual(release.data.assets[0].name, "TEST.md")
const actual = await github.request(release.data.assets[0].browser_download_url)
assert.deepStrictEqual(expected, actual.data)
- name: Clean up - name: Clean up
if: ${{ always() }} if: ${{ always() }}
uses: actions/github-script@v2 uses: actions/github-script@v2

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@ node_modules
run.sh run.sh
__tests__/runner/* __tests__/runner/*
lib/**/* lib/**/*
.idea

View File

@@ -1,5 +1,25 @@
# Changelog # Changelog
## [2.6.0] - 2023-05-23
- Add `make_latest` input parameter. Can be set to `false` to prevent the created release from being marked as the latest release for the repository [#100](https://github.com/svenstaro/upload-release-action/pull/100) (thanks @brandonkelly)
- Don't try to upload empty files [#102](https://github.com/svenstaro/upload-release-action/pull/102) (thanks @Loyalsoldier)
- Bump all deps [#105](https://github.com/svenstaro/upload-release-action/pull/105)
- `overwrite` option also overwrites name and body [#106](https://github.com/svenstaro/upload-release-action/pull/106) (thanks @regevbr)
- Add `promote` option to allow prereleases to be promoted [#74](https://github.com/svenstaro/upload-release-action/pull/74) (thanks @regevbr)
## [2.5.0] - 2023-02-21
- Add retry to upload release [#96](https://github.com/svenstaro/upload-release-action/pull/96) (thanks @sonphantrung)
## [2.4.1] - 2023-02-01
- Modernize octokit usage
## [2.4.0] - 2023-01-09
- Update to node 16
- Bump most dependencies
## [2.3.0] - 2022-06-05
- Now defaults `repo_token` to `${{ github.token }}` and `tag` to `${{ github.ref }}` [#69](https://github.com/svenstaro/upload-release-action/pull/69) (thanks @leighmcculloch)
## [2.2.1] - 2020-12-16 ## [2.2.1] - 2020-12-16
- Added support for the GitHub pagination API for repositories with many releases [#36](https://github.com/svenstaro/upload-release-action/pull/36) (thanks @djpohly) - Added support for the GitHub pagination API for repositories with many releases [#36](https://github.com/svenstaro/upload-release-action/pull/36) (thanks @djpohly)

View File

@@ -1,4 +1,4 @@
# Upload files to a GitHub release [![GitHub Actions Workflow](https://github.com/svenstaro/upload-release-action/workflows/PR%20Checks/badge.svg)](https://github.com/svenstaro/upload-release-action/actions) # Upload files to a GitHub release [![GitHub Actions Workflow](https://github.com/svenstaro/upload-release-action/actions/workflows/ci.yml/badge.svg)](https://github.com/svenstaro/upload-release-action/actions)
This action allows you to select which files to upload to the just-tagged release. This action allows you to select which files to upload to the just-tagged release.
It runs on all operating systems types offered by GitHub. It runs on all operating systems types offered by GitHub.
@@ -7,17 +7,19 @@ It runs on all operating systems types offered by GitHub.
You must provide: You must provide:
- `repo_token`: Usually you'll want to set this to `${{ secrets.GITHUB_TOKEN }}`.
- `file`: A local file to be uploaded as the asset. - `file`: A local file to be uploaded as the asset.
- `tag`: The tag to upload into. If you want the current event's tag or branch name, use `${{ github.ref }}` (the `refs/tags/` and `refs/heads/` prefixes will be automatically stripped).
Optional Arguments Optional Arguments
- `repo_token`: Defaults to `github.token`.
- `tag`: The tag to upload into. If you want the current event's tag or branch name, use `${{ github.ref }}` (the `refs/tags/` and `refs/heads/` prefixes will be automatically stripped). Defaults to `github.ref`.
- `asset_name`: The name the file gets as an asset on a release. Use `$tag` to include the tag name. When not provided it will default to the filename. - `asset_name`: The name the file gets as an asset on a release. Use `$tag` to include the tag name. When not provided it will default to the filename.
This is not used if `file_glob` is set to `true`. This is not used if `file_glob` is set to `true`.
- `file_glob`: If set to true, the file argument can be a glob pattern (`asset_name` is ignored in this case) (Default: `false`) - `file_glob`: If set to true, the `file` argument can be a glob pattern (`asset_name` is ignored in this case) (Default: `false`)
- `overwrite`: If an asset with the same name already exists, overwrite it (Default: `false`). - `overwrite`: If an asset with the same name already exists, overwrite it (Default: `false`).
- `promote`: If a prerelease already exists, promote it to a release (Default: `false`).
- `prerelease`: Mark the release as a pre-release (Default: `false`). - `prerelease`: Mark the release as a pre-release (Default: `false`).
- `make_latest`: Mark the release as the latest release for the repository (Default: `true`).
- `release_name`: Explicitly set a release name. (Defaults: implicitly same as `tag` via GitHub API). - `release_name`: Explicitly set a release name. (Defaults: implicitly same as `tag` via GitHub API).
- `body`: Content of the release text (Default: `""`). - `body`: Content of the release text (Default: `""`).
- `repo_name`: Specify the name of the GitHub repository in which the GitHub release will be created, edited, and deleted. If the repository is other than the current, it is required to create a personal access token with `repo`, `user`, `admin:repo_hook` scopes to the foreign repository and add it as a secret. (Default: current repository). - `repo_name`: Specify the name of the GitHub repository in which the GitHub release will be created, edited, and deleted. If the repository is other than the current, it is required to create a personal access token with `repo`, `user`, `admin:repo_hook` scopes to the foreign repository and add it as a secret. (Default: current repository).
@@ -47,7 +49,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Build - name: Build
run: cargo build --release run: cargo build --release
- name: Upload binaries to release - name: Upload binaries to release
@@ -89,7 +91,7 @@ jobs:
asset_name: mything-macos-amd64 asset_name: mything-macos-amd64
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Build - name: Build
run: cargo build --release --locked run: cargo build --release --locked
- name: Upload binaries to release - name: Upload binaries to release
@@ -115,7 +117,7 @@ jobs:
name: Publish binaries name: Publish binaries
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Build - name: Build
run: cargo build --release run: cargo build --release
- name: Upload binaries to release - name: Upload binaries to release
@@ -144,7 +146,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Build - name: Build
run: cargo build --release run: cargo build --release
- name: Upload binaries to release - name: Upload binaries to release
@@ -161,6 +163,61 @@ jobs:
body: "This is my release text" body: "This is my release text"
``` ```
**Example for feeding a file from repo to the `body` tag:**
This example covers following points:
* Reading a file present on the repo. For example, `release.md` which is placed in root directory of the repo.
* Modify & push the `release.md` file before triggering this action (create tag for this example) to dynamically change the body of the release.
```yaml
name: Publish
on:
push:
tags:
- '*'
jobs:
build:
name: Publish binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# This step reads a file from repo and use it for body of the release
# This works on any self-hosted runner OS
- name: Read release.md and use it as a body of new release
id: read_release
shell: bash
run: |
r=$(cat path/to/release.md) # <--- Read release.md (Provide correct path as per your repo)
r="${r//'%'/'%25'}" # Multiline escape sequences for %
r="${r//$'\n'/'%0A'}" # Multiline escape sequences for '\n'
r="${r//$'\r'/'%0D'}" # Multiline escape sequences for '\r'
echo "RELEASE_BODY=$r" >> $GITHUB_OUTPUT # <--- Set environment variable
- name: Upload Binaries to Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
body: |
${{ steps.read_release.outputs.RELEASE_BODY }} # <--- Use environment variables that was created earlier
```
### Permissions
This actions requires writes access to the release. If you are using [granular permissions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions)
in your workflow, you will need to add the `contents: write` permission to the token:
```yaml
permissions:
contents: write
```
## Releasing ## Releasing
To release this Action: To release this Action:

View File

@@ -8,20 +8,26 @@ inputs:
repo_token: repo_token:
description: 'GitHub token.' description: 'GitHub token.'
required: true required: true
default: ${{ github.token }}
file: file:
description: 'Local file to upload.' description: 'Local file to upload.'
required: true required: true
tag: tag:
description: 'Tag to use as a release.' description: 'Tag to use as a release.'
required: true required: true
default: ${{ github.ref }}
asset_name: asset_name:
description: 'Name of the asset. When not provided will use the file name. Unused if file_glob is set to "true".' description: 'Name of the asset. When not provided will use the file name. Unused if file_glob is set to "true".'
overwrite: overwrite:
description: 'Overwrite the release in case it already exists.' description: 'Overwrite the release in case it already exists.'
promote:
description: 'Promote a prerelease to release. Defaults to "false".'
file_glob: file_glob:
description: 'If true the file can be a glob pattern, asset_name is ignored if this is true.' description: 'If true the file can be a glob pattern, asset_name is ignored if this is true.'
prerelease: prerelease:
description: 'Mark the release as a pre-release. Defaults to "false".' description: 'Mark the release as a pre-release. Defaults to "false".'
make_latest:
description: 'Mark the release the latest release for the repository. Defaults to "true".'
release_name: release_name:
description: 'Explicitly set a release name. Defaults to empty which will cause the release to take the tag as name on GitHub.' description: 'Explicitly set a release name. Defaults to empty which will cause the release to take the tag as name on GitHub.'
body: body:
@@ -32,5 +38,5 @@ outputs:
browser_download_url: browser_download_url:
description: 'The publicly available URL of the asset.' description: 'The publicly available URL of the asset.'
runs: runs:
using: 'node12' using: 'node16'
main: 'dist/index.js' main: 'dist/index.js'

25857
dist/index.js vendored

File diff suppressed because one or more lines are too long

17736
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "upload-release-action", "name": "upload-release-action",
"version": "2.2.1", "version": "2.6.0",
"private": true, "private": true,
"description": "Upload files to a GitHub release", "description": "Upload files to a GitHub release",
"main": "lib/main.js", "main": "lib/main.js",
@@ -27,24 +27,27 @@
"author": "Sven-Hendrik Haase", "author": "Sven-Hendrik Haase",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.10.0",
"@actions/github": "^4.0.0", "@actions/github": "^5.1.1",
"@types/glob": "^7.1.2", "@lifeomic/attempt": "^3.0.3",
"glob": "^7.1.6" "@octokit/core": "^4.2.1",
"glob": "^10"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^24.9.1", "@octokit/types": "^9.2.3",
"@types/node": "^12.12.64", "@types/glob": "^8",
"@typescript-eslint/parser": "^3.5.0", "@types/jest": "^29",
"@zeit/ncc": "^0.22.3", "@types/node": "^16",
"eslint": "^7.10.0", "@typescript-eslint/parser": "^5",
"eslint-plugin-github": "^4.0.1", "@vercel/ncc": "^0.36.1",
"eslint-plugin-jest": "^23.17.1", "eslint": "^8",
"jest": "^26.5.2", "eslint-plugin-github": "^4.7",
"jest-circus": "^26.5.2", "eslint-plugin-jest": "^27",
"js-yaml": "^3.14.0", "jest": "^29",
"prettier": "^2.0.5", "jest-circus": "^29",
"ts-jest": "^26.4.1", "js-yaml": "^4",
"typescript": "^3.9.6" "prettier": "^2.8",
"ts-jest": "^29",
"typescript": "^5"
} }
} }

View File

@@ -5,35 +5,54 @@ import * as core from '@actions/core'
import * as github from '@actions/github' import * as github from '@actions/github'
import * as path from 'path' import * as path from 'path'
import * as glob from 'glob' import * as glob from 'glob'
import {retry} from '@lifeomic/attempt'
type RepoAssetsResp = Endpoints['GET /repos/:owner/:repo/releases/:release_id/assets']['response']['data'] const releaseByTag = 'GET /repos/{owner}/{repo}/releases/tags/{tag}' as const
type ReleaseByTagResp = Endpoints['GET /repos/:owner/:repo/releases/tags/:tag']['response'] const createRelease = 'POST /repos/{owner}/{repo}/releases' as const
type CreateReleaseResp = Endpoints['POST /repos/:owner/:repo/releases']['response'] const updateRelease =
type UploadAssetResp = Endpoints['POST /repos/:owner/:repo/releases/:release_id/assets{?name,label}']['response'] 'PATCH /repos/{owner}/{repo}/releases/{release_id}' as const
const repoAssets =
'GET /repos/{owner}/{repo}/releases/{release_id}/assets' as const
const uploadAssets =
'POST {origin}/repos/{owner}/{repo}/releases/{release_id}/assets{?name,label}' as const
const deleteAssets =
'DELETE /repos/{owner}/{repo}/releases/assets/{asset_id}' as const
type ReleaseByTagResp = Endpoints[typeof releaseByTag]['response']
type CreateReleaseResp = Endpoints[typeof createRelease]['response']
type RepoAssetsResp = Endpoints[typeof repoAssets]['response']['data']
type UploadAssetResp = Endpoints[typeof uploadAssets]['response']
type UpdateReleaseResp = Endpoints[typeof updateRelease]['response']
type UpdateReleaseParams = Endpoints[typeof updateRelease]['parameters']
async function get_release_by_tag( async function get_release_by_tag(
tag: string, tag: string,
prerelease: boolean, prerelease: boolean,
make_latest: boolean,
release_name: string, release_name: string,
body: string, body: string,
octokit: Octokit octokit: Octokit,
): Promise<ReleaseByTagResp | CreateReleaseResp> { overwrite: boolean,
promote: boolean
): Promise<ReleaseByTagResp | CreateReleaseResp | UpdateReleaseResp> {
let release: ReleaseByTagResp
try { try {
core.debug(`Getting release by tag ${tag}.`) core.debug(`Getting release by tag ${tag}.`)
return await octokit.repos.getReleaseByTag({ release = await octokit.request(releaseByTag, {
...repo(), ...repo(),
tag: tag tag: tag
}) })
} catch (error) { } catch (error: any) {
// If this returns 404, we need to create the release first. // If this returns 404, we need to create the release first.
if (error.status === 404) { if (error.status === 404) {
core.debug( core.debug(
`Release for tag ${tag} doesn't exist yet so we'll create it now.` `Release for tag ${tag} doesn't exist yet so we'll create it now.`
) )
return await octokit.repos.createRelease({ return await octokit.request(createRelease, {
...repo(), ...repo(),
tag_name: tag, tag_name: tag,
prerelease: prerelease, prerelease: prerelease,
make_latest: make_latest ? 'true' : 'false',
name: release_name, name: release_name,
body: body body: body
}) })
@@ -41,15 +60,45 @@ async function get_release_by_tag(
throw error throw error
} }
} }
let updateObject: Partial<UpdateReleaseParams> | undefined
if (promote && release.data.prerelease) {
core.debug(`The ${tag} is a prerelease, promoting it to a release.`)
updateObject = updateObject || {}
updateObject.prerelease = false
}
if (overwrite) {
if (release.data.name !== release_name) {
core.debug(
`The ${tag} release already exists with a different name ${release.data.name} so we'll overwrite it.`
)
updateObject = updateObject || {}
updateObject.name = release_name
}
if (release.data.body !== body) {
core.debug(
`The ${tag} release already exists with a different body ${release.data.body} so we'll overwrite it.`
)
updateObject = updateObject || {}
updateObject.body = body
}
}
if (updateObject) {
return octokit.request(updateRelease, {
...repo(),
...updateObject,
release_id: release.data.id
})
}
return release
} }
async function upload_to_release( async function upload_to_release(
release: ReleaseByTagResp | CreateReleaseResp, release: ReleaseByTagResp | CreateReleaseResp | UpdateReleaseResp,
file: string, file: string,
asset_name: string, asset_name: string,
tag: string, tag: string,
overwrite: boolean, overwrite: boolean,
octokit: Octokit octokit: ReturnType<(typeof github)['getOctokit']>
): Promise<undefined | string> { ): Promise<undefined | string> {
const stat = fs.statSync(file) const stat = fs.statSync(file)
if (!stat.isFile()) { if (!stat.isFile()) {
@@ -57,23 +106,23 @@ async function upload_to_release(
return return
} }
const file_size = stat.size const file_size = stat.size
const file_bytes = fs.readFileSync(file) if (file_size === 0) {
core.debug(`Skipping ${file}, since its size is 0`)
return
}
// Check for duplicates. // Check for duplicates.
const assets: RepoAssetsResp = await octokit.paginate( const assets: RepoAssetsResp = await octokit.paginate(repoAssets, {
octokit.repos.listReleaseAssets,
{
...repo(), ...repo(),
release_id: release.data.id release_id: release.data.id
} })
)
const duplicate_asset = assets.find(a => a.name === asset_name) const duplicate_asset = assets.find(a => a.name === asset_name)
if (duplicate_asset !== undefined) { if (duplicate_asset !== undefined) {
if (overwrite) { if (overwrite) {
core.debug( core.debug(
`An asset called ${asset_name} already exists in release ${tag} so we'll overwrite it.` `An asset called ${asset_name} already exists in release ${tag} so we'll overwrite it.`
) )
await octokit.repos.deleteReleaseAsset({ await octokit.request(deleteAssets, {
...repo(), ...repo(),
asset_id: duplicate_asset.id asset_id: duplicate_asset.id
}) })
@@ -88,15 +137,22 @@ async function upload_to_release(
} }
core.debug(`Uploading ${file} to ${asset_name} in release ${tag}.`) core.debug(`Uploading ${file} to ${asset_name} in release ${tag}.`)
const uploaded_asset: UploadAssetResp = await octokit.repos.uploadReleaseAsset( const uploaded_asset: UploadAssetResp = await retry(
{ async () => {
return octokit.request(uploadAssets, {
...repo(),
release_id: release.data.id,
url: release.data.upload_url, url: release.data.upload_url,
name: asset_name, name: asset_name,
data: file_bytes, data: fs.createReadStream(file) as any,
headers: { headers: {
'content-type': 'binary/octet-stream', 'content-type': 'binary/octet-stream',
'content-length': file_size 'content-length': file_size
} }
})
},
{
maxAttempts: 3
} }
) )
return uploaded_asset.data.browser_download_url return uploaded_asset.data.browser_download_url
@@ -108,17 +164,17 @@ function repo(): {owner: string; repo: string} {
if (!repo_name) { if (!repo_name) {
return github.context.repo return github.context.repo
} }
const owner = repo_name.substr(0, repo_name.indexOf('/')) const owner = repo_name.substring(0, repo_name.indexOf('/'))
if (!owner) { if (!owner) {
throw new Error(`Could not extract 'owner' from 'repo_name': ${repo_name}.`) throw new Error(`Could not extract 'owner' from 'repo_name': ${repo_name}.`)
} }
const repo = repo_name.substr(repo_name.indexOf('/') + 1) const repo_ = repo_name.substring(repo_name.indexOf('/') + 1)
if (!repo) { if (!repo_) {
throw new Error(`Could not extract 'repo' from 'repo_name': ${repo_name}.`) throw new Error(`Could not extract 'repo' from 'repo_name': ${repo_name}.`)
} }
return { return {
owner, owner,
repo repo: repo_
} }
} }
@@ -134,27 +190,36 @@ async function run(): Promise<void> {
const file_glob = core.getInput('file_glob') == 'true' ? true : false const file_glob = core.getInput('file_glob') == 'true' ? true : false
const overwrite = core.getInput('overwrite') == 'true' ? true : false const overwrite = core.getInput('overwrite') == 'true' ? true : false
const promote = core.getInput('promote') == 'true' ? true : false
const prerelease = core.getInput('prerelease') == 'true' ? true : false const prerelease = core.getInput('prerelease') == 'true' ? true : false
const make_latest = core.getInput('make_latest') != 'false' ? true : false
const release_name = core.getInput('release_name') const release_name = core.getInput('release_name')
const body = core.getInput('body') const body = core
.getInput('body')
.replace(/%0A/gi, '\n')
.replace(/%0D/gi, '\r')
.replace(/%25/g, '%')
const octokit: Octokit = github.getOctokit(token) const octokit = github.getOctokit(token)
const release = await get_release_by_tag( const release = await get_release_by_tag(
tag, tag,
prerelease, prerelease,
make_latest,
release_name, release_name,
body, body,
octokit octokit,
overwrite,
promote
) )
if (file_glob) { if (file_glob) {
const files = glob.sync(file) const files = glob.sync(file)
if (files.length > 0) { if (files.length > 0) {
for (const file of files) { for (const file_ of files) {
const asset_name = path.basename(file) const asset_name = path.basename(file_)
const asset_download_url = await upload_to_release( const asset_download_url = await upload_to_release(
release, release,
file, file_,
asset_name, asset_name,
tag, tag,
overwrite, overwrite,
@@ -180,7 +245,7 @@ async function run(): Promise<void> {
) )
core.setOutput('browser_download_url', asset_download_url) core.setOutput('browser_download_url', asset_download_url)
} }
} catch (error) { } catch (error: any) {
core.setFailed(error.message) core.setFailed(error.message)
} }
} }