chore(action) rollback to github 2.2.0

This commit is contained in:
Lucas Nogueira
2020-07-08 00:37:46 -03:00
parent 5bdcda3793
commit 0484cda42d
9 changed files with 123 additions and 60 deletions

View File

@@ -7,7 +7,7 @@ jobs:
create-release:
runs-on: ubuntu-latest
outputs:
RELEASE_UPLOAD_ID: ${{ steps.create_tauri_release.outputs.upload_id }}
RELEASE_UPLOAD_URL: ${{ steps.create_tauri_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v2
@@ -67,4 +67,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
projectPath: ./example
releaseId: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }}
uploadUrl: ${{ needs.create-release.outputs.RELEASE_UPLOAD_URL }}

View File

@@ -18,7 +18,7 @@ jobs:
create-release:
runs-on: ubuntu-latest
outputs:
RELEASE_UPLOAD_ID: ${{ steps.create_tauri_release.outputs.upload_id }}
RELEASE_UPLOAD_URL: ${{ steps.create_tauri_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v2
@@ -75,7 +75,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseId: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }}
uploadUrl: ${{ needs.create-release.outputs.RELEASE_UPLOAD_URL }}
```
## Inputs
@@ -85,4 +85,4 @@ jobs:
| `projectPath` | false | Path to the root of the project that will be built | string | . |
| `configPath` | false | Path to the tauri.conf.json file if you want a configuration different from the default one | string | tauri.conf.json |
| `distPath` | false | Path to the distributable folder with your index.html and JS/CSS | string | |
| `releaseId` | false | The id of the release to upload the assets | number | |
| `uploadUrl` | false | The URL for uploading assets to the release | string | |

View File

@@ -2,8 +2,8 @@ name: 'Your name here'
description: 'Provide a description here'
author: 'Lucas Nogueira <lucas@tauri.studio>'
inputs:
releaseId:
description: 'The id of the release to upload assets'
uploadUrl:
description: 'The URL for uploading assets to the release'
projectPath:
description: 'path to the root of the project that will be built'
default: '.'

6
dist/main.js vendored
View File

@@ -121,9 +121,9 @@ function run() {
const projectPath = path_1.resolve(process.cwd(), core.getInput('projectPath') || process.argv[2]);
const configPath = path_1.join(projectPath, core.getInput('configPath') || 'tauri.conf.json');
const distPath = core.getInput('distPath');
const releaseId = core.getInput('releaseId');
const uploadUrl = core.getInput('uploadUrl');
const artifacts = yield buildProject(projectPath, false, { configPath: fs_1.existsSync(configPath) ? configPath : null, distPath });
if (releaseId) {
if (uploadUrl) {
if (os_1.platform() === 'darwin') {
let index = -1;
let i = 0;
@@ -138,7 +138,7 @@ function run() {
artifacts[index] = artifacts[index] + '.tgz';
}
}
yield upload_release_assets_1.default(Number(releaseId), artifacts);
yield upload_release_assets_1.default(uploadUrl, artifacts);
}
}
catch (error) {

View File

@@ -35,24 +35,22 @@ const core = __importStar(require("@actions/core"));
const github_1 = require("@actions/github");
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
function uploadAssets(releaseId, assets) {
function uploadAssets(uploadUrl, assets) {
return __awaiter(this, void 0, void 0, function* () {
try {
if (process.env.GITHUB_TOKEN === undefined) {
throw new Error('GITHUB_TOKEN is required');
}
const github = github_1.getOctokit(process.env.GITHUB_TOKEN);
const github = new github_1.GitHub(process.env.GITHUB_TOKEN);
// Determine content-length for header to upload asset
const contentLength = (filePath) => fs_1.default.statSync(filePath).size;
for (const assetPath of assets) {
const headers = { 'content-type': 'application/zip', 'content-length': contentLength(assetPath) };
yield github.repos.uploadReleaseAsset({
release_id: releaseId,
url: uploadUrl,
headers,
name: path_1.default.basename(assetPath),
data: fs_1.default.readFileSync(assetPath).toString(),
repo: github_1.context.repo.repo,
owner: github_1.context.repo.owner
data: fs_1.default.readFileSync(assetPath)
});
}
}

View File

@@ -25,7 +25,7 @@
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/github": "^4.0.0",
"@actions/github": "^2.2.0",
"execa": "^4.0.3"
},
"devDependencies": {

View File

@@ -91,11 +91,11 @@ async function run(): Promise<void> {
const projectPath = resolve(process.cwd(), core.getInput('projectPath') || process.argv[2])
const configPath = join(projectPath, core.getInput('configPath') || 'tauri.conf.json')
const distPath = core.getInput('distPath')
const releaseId = core.getInput('releaseId')
const uploadUrl = core.getInput('uploadUrl')
const artifacts = await buildProject(projectPath, false, { configPath: existsSync(configPath) ? configPath : null, distPath })
if (releaseId) {
if (uploadUrl) {
if (platform() === 'darwin') {
let index = -1
let i = 0
@@ -110,7 +110,7 @@ async function run(): Promise<void> {
artifacts[index] = artifacts[index] + '.tgz'
}
}
await uploadReleaseAssets(Number(releaseId), artifacts)
await uploadReleaseAssets(uploadUrl, artifacts)
}
} catch (error) {
core.setFailed(error.message)

View File

@@ -1,15 +1,15 @@
import * as core from '@actions/core'
import { getOctokit, context } from '@actions/github'
import { GitHub } from '@actions/github'
import fs from 'fs'
import path from 'path'
export default async function uploadAssets(releaseId: number, assets: string[]) {
export default async function uploadAssets(uploadUrl: string, assets: string[]) {
try {
if (process.env.GITHUB_TOKEN === undefined) {
throw new Error('GITHUB_TOKEN is required')
}
const github = getOctokit(process.env.GITHUB_TOKEN)
const github = new GitHub(process.env.GITHUB_TOKEN)
// Determine content-length for header to upload asset
const contentLength = (filePath: string) => fs.statSync(filePath).size
@@ -18,12 +18,10 @@ export default async function uploadAssets(releaseId: number, assets: string[])
const headers = { 'content-type': 'application/zip', 'content-length': contentLength(assetPath) }
await github.repos.uploadReleaseAsset({
release_id: releaseId,
url: uploadUrl,
headers,
name: path.basename(assetPath),
data: fs.readFileSync(assetPath).toString(),
repo: context.repo.repo,
owner: context.repo.owner
data: fs.readFileSync(assetPath)
})
}
} catch (error) {

133
yarn.lock
View File

@@ -7,17 +7,16 @@
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.4.tgz#96179dbf9f8d951dd74b40a0dbd5c22555d186ab"
integrity sha512-YJCEq8BE3CdN8+7HPZ/4DxJjk/OkZV2FFIf+DlZTC/4iBlzYCD5yjRR6eiOS5llO11zbRltIRuKAjMKaWTE6cg==
"@actions/github@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@actions/github/-/github-4.0.0.tgz#d520483151a2bf5d2dc9cd0f20f9ac3a2e458816"
integrity sha512-Ej/Y2E+VV6sR9X7pWL5F3VgEWrABaT292DRqRU6R4hnQjPtC/zD3nagxVdXWiRQvYDh8kHXo7IDmG42eJ/dOMA==
"@actions/github@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@actions/github/-/github-2.2.0.tgz#8952fe96b12b881fa39340f0e7202b04dc5c3e71"
integrity sha512-9UAZqn8ywdR70n3GwVle4N8ALosQs4z50N7XMXrSTUVOmVpaBC5kE3TRTT7qQdi3OaQV24mjGuJZsHUmhD+ZXw==
dependencies:
"@actions/http-client" "^1.0.8"
"@octokit/core" "^3.0.0"
"@octokit/plugin-paginate-rest" "^2.2.3"
"@octokit/plugin-rest-endpoint-methods" "^4.0.0"
"@actions/http-client" "^1.0.3"
"@octokit/graphql" "^4.3.1"
"@octokit/rest" "^16.43.1"
"@actions/http-client@^1.0.8":
"@actions/http-client@^1.0.3":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.8.tgz#8bd76e8eca89dc8bcf619aa128eba85f7a39af45"
integrity sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==
@@ -518,18 +517,6 @@
dependencies:
"@octokit/types" "^5.0.0"
"@octokit/core@^3.0.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.1.0.tgz#9c3c9b23f7504668cfa057f143ccbf0c645a0ac9"
integrity sha512-yPyQSmxIXLieEIRikk2w8AEtWkFdfG/LXcw1KvEtK3iP0ENZLW/WYQmdzOKqfSaLhooz4CJ9D+WY79C8ZliACw==
dependencies:
"@octokit/auth-token" "^2.4.0"
"@octokit/graphql" "^4.3.1"
"@octokit/request" "^5.4.0"
"@octokit/types" "^5.0.0"
before-after-hook "^2.1.0"
universal-user-agent "^5.0.0"
"@octokit/endpoint@^6.0.1":
version "6.0.3"
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.3.tgz#dd09b599662d7e1b66374a177ab620d8cdf73487"
@@ -548,21 +535,35 @@
"@octokit/types" "^5.0.0"
universal-user-agent "^5.0.0"
"@octokit/plugin-paginate-rest@^2.2.3":
version "2.2.3"
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.2.3.tgz#a6ad4377e7e7832fb4bdd9d421e600cb7640ac27"
integrity sha512-eKTs91wXnJH8Yicwa30jz6DF50kAh7vkcqCQ9D7/tvBAP5KKkg6I2nNof8Mp/65G0Arjsb4QcOJcIEQY+rK1Rg==
"@octokit/plugin-paginate-rest@^1.1.1":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-1.1.2.tgz#004170acf8c2be535aba26727867d692f7b488fc"
integrity sha512-jbsSoi5Q1pj63sC16XIUboklNw+8tL9VOnJsWycWYR78TKss5PVpIPb1TUUcMQ+bBh7cY579cVAWmf5qG+dw+Q==
dependencies:
"@octokit/types" "^5.0.0"
"@octokit/types" "^2.0.1"
"@octokit/plugin-rest-endpoint-methods@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.0.0.tgz#b02a2006dda8e908c3f8ab381dd5475ef5a810a8"
integrity sha512-emS6gysz4E9BNi9IrCl7Pm4kR+Az3MmVB0/DoDCmF4U48NbYG3weKyDlgkrz6Jbl4Mu4nDx8YWZwC4HjoTdcCA==
"@octokit/plugin-request-log@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e"
integrity sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw==
"@octokit/plugin-rest-endpoint-methods@2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-2.4.0.tgz#3288ecf5481f68c494dd0602fc15407a59faf61e"
integrity sha512-EZi/AWhtkdfAYi01obpX0DF7U6b1VRr30QNQ5xSFPITMdLSfhcBqjamE3F+sKcxPbD7eZuMHu3Qkk2V+JGxBDQ==
dependencies:
"@octokit/types" "^5.0.0"
"@octokit/types" "^2.0.1"
deprecation "^2.3.1"
"@octokit/request-error@^1.0.2":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.2.1.tgz#ede0714c773f32347576c25649dc013ae6b31801"
integrity sha512-+6yDyk1EES6WK+l3viRDElw96MvwfJxCt45GvmjDUKWjYIb3PJZQkq3i46TwGwoPD4h8NmTrENmtyA1FwbmhRA==
dependencies:
"@octokit/types" "^2.0.0"
deprecation "^2.0.0"
once "^1.4.0"
"@octokit/request-error@^2.0.0":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.0.2.tgz#0e76b83f5d8fdda1db99027ea5f617c2e6ba9ed0"
@@ -572,7 +573,7 @@
deprecation "^2.0.0"
once "^1.4.0"
"@octokit/request@^5.3.0", "@octokit/request@^5.4.0":
"@octokit/request@^5.2.0", "@octokit/request@^5.3.0":
version "5.4.5"
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.4.5.tgz#8df65bd812047521f7e9db6ff118c06ba84ac10b"
integrity sha512-atAs5GAGbZedvJXXdjtKljin+e2SltEs48B3naJjqWupYl2IUBbB/CJisyjbNHcKpHzb3E+OYEZ46G8eakXgQg==
@@ -586,6 +587,35 @@
once "^1.4.0"
universal-user-agent "^5.0.0"
"@octokit/rest@^16.43.1":
version "16.43.2"
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.43.2.tgz#c53426f1e1d1044dee967023e3279c50993dd91b"
integrity sha512-ngDBevLbBTFfrHZeiS7SAMAZ6ssuVmXuya+F/7RaVvlysgGa1JKJkKWY+jV6TCJYcW0OALfJ7nTIGXcBXzycfQ==
dependencies:
"@octokit/auth-token" "^2.4.0"
"@octokit/plugin-paginate-rest" "^1.1.1"
"@octokit/plugin-request-log" "^1.0.0"
"@octokit/plugin-rest-endpoint-methods" "2.4.0"
"@octokit/request" "^5.2.0"
"@octokit/request-error" "^1.0.2"
atob-lite "^2.0.0"
before-after-hook "^2.0.0"
btoa-lite "^1.0.0"
deprecation "^2.0.0"
lodash.get "^4.4.2"
lodash.set "^4.3.2"
lodash.uniq "^4.5.0"
octokit-pagination-methods "^1.1.0"
once "^1.4.0"
universal-user-agent "^4.0.0"
"@octokit/types@^2.0.0", "@octokit/types@^2.0.1":
version "2.16.2"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.16.2.tgz#4c5f8da3c6fecf3da1811aef678fda03edac35d2"
integrity sha512-O75k56TYvJ8WpAakWwYRN8Bgu60KrmX0z1KqFp1kNiFNkgW+JW+9EBKZ+S33PU6SLvbihqd+3drvPxKK68Ee8Q==
dependencies:
"@types/node" ">= 8"
"@octokit/types@^5.0.0", "@octokit/types@^5.0.1":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-5.0.1.tgz#5459e9a5e9df8565dcc62c17a34491904d71971e"
@@ -977,6 +1007,11 @@ at-least-node@^1.0.0:
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
atob-lite@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/atob-lite/-/atob-lite-2.0.0.tgz#0fef5ad46f1bd7a8502c65727f0367d5ee43d696"
integrity sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=
atob@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
@@ -1082,7 +1117,7 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"
before-after-hook@^2.1.0:
before-after-hook@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635"
integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A==
@@ -1151,6 +1186,11 @@ bser@2.1.1:
dependencies:
node-int64 "^0.4.0"
btoa-lite@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/btoa-lite/-/btoa-lite-1.0.0.tgz#337766da15801210fdd956c22e9c6891ab9d0337"
integrity sha1-M3dm2hWAEhD92VbCLpxokaudAzc=
buffer-from@1.x, buffer-from@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
@@ -3352,11 +3392,21 @@ lodash.flatten@^4.4.0:
resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"
integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=
lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=
lodash.memoize@4.x:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=
lodash.set@^4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=
lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
@@ -3367,6 +3417,11 @@ lodash.unescape@4.0.1:
resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c"
integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=
lodash.uniq@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
lodash.without@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.without/-/lodash.without-4.4.0.tgz#3cd4574a00b67bae373a94b748772640507b7aac"
@@ -3726,6 +3781,11 @@ object.values@^1.1.1:
function-bind "^1.1.1"
has "^1.0.3"
octokit-pagination-methods@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/octokit-pagination-methods/-/octokit-pagination-methods-1.1.0.tgz#cf472edc9d551055f9ef73f6e42b4dbb4c80bea4"
integrity sha512-fZ4qZdQ2nxJvtcasX7Ghl+WlWS/d9IgnBIwFZXVNNZUmzpno91SX5bc5vuxiuKoCtK78XxGGNuSCrDC7xYB3OQ==
once@^1.3.0, once@^1.3.1, once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
@@ -4911,6 +4971,13 @@ union-value@^1.0.0:
is-extendable "^0.1.1"
set-value "^2.0.1"
universal-user-agent@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-4.0.1.tgz#fd8d6cb773a679a709e967ef8288a31fcc03e557"
integrity sha512-LnST3ebHwVL2aNe4mejI9IQh2HfZ1RLo8Io2HugSif8ekzD1TlWpHpColOB/eh8JHMLkGH3Akqf040I+4ylNxg==
dependencies:
os-name "^3.1.0"
universal-user-agent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-5.0.0.tgz#a3182aa758069bf0e79952570ca757de3579c1d9"