-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automated deployment: Wed Nov 13 13:49:11 UTC 2019 27bd5d3
- Loading branch information
0 parents
commit 34e8787
Showing
27 changed files
with
1,742 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
- '!latest' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Pull sources | ||
uses: actions/checkout@v1 | ||
|
||
- name: Configure Node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '10.x' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Publish | ||
if: github.event.ref == 'refs/heads/master' | ||
run: | | ||
remote_branch=latest | ||
git checkout --orphan "$remote_branch" | ||
git config user.name "$GITHUB_ACTOR" | ||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
git remote rm origin || true | ||
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | ||
git remote add origin "$remote_repo" | ||
git add --all | ||
COMMIT_MESSAGE="Automated deployment: $(date -u) $GITHUB_SHA" | ||
git commit -m "$COMMIT_MESSAGE" | true | ||
git push origin "$remote_branch" --force | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Boost Software License - Version 1.0 - August 17th, 2003 | ||
|
||
Permission is hereby granted, free of charge, to any person or organization | ||
obtaining a copy of the software and accompanying documentation covered by | ||
this license (the "Software") to use, reproduce, display, distribute, | ||
execute, and transmit the Software, and to prepare derivative works of the | ||
Software, and to permit third-parties to whom the Software is furnished to | ||
do so, all subject to the following: | ||
|
||
The copyright notices in the Software and this entire statement, including | ||
the above license grant, this restriction and the following disclaimer, | ||
must be included in all copies of the Software, in whole or in part, and | ||
all derivative works of the Software, unless such copies or derivative | ||
works are solely in the form of machine-executable object code generated by | ||
a source language processor. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | ||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | ||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
= conan-upload | ||
:toc: preamble | ||
|
||
[link=https://github.com/grisumbras/conan-upload/actions] | ||
image::https://github.com/grisumbras/conan-upload/workflows/ci/badge.svg[Build status] | ||
|
||
____ | ||
GitHub Action that uploads a package to Conan server | ||
____ | ||
|
||
|
||
== Usage | ||
The action authenticates against the Conan remote to upload to, then uploads a | ||
package. | ||
|
||
Example usage: | ||
|
||
[source,yaml] | ||
---- | ||
uses: grisumbras/conan-upload@latest | ||
with: | ||
login: johndoe | ||
password: ${{ secrets.SECRET_CONAN_PASSSWORD }} | ||
url: https://api.bintray.com/conan/johndoe/conan-public | ||
---- | ||
|
||
|
||
== Inputs | ||
|
||
=== `login` | ||
Username to authenticate as. If not present package's user is used. | ||
|
||
=== `password` | ||
Password to use to authenticate. This is normally stored as a repository | ||
secret. | ||
|
||
=== `url` | ||
URL of the remote to upload to. If not specified, `CONAN_UPLOAD` environment | ||
variable is used. | ||
|
||
=== `remote` | ||
URL of the remote to upload to. If not specified, the string `upload` is used. | ||
|
||
=== `name` | ||
Name of the package to export. If not specified, `name` attribute of the | ||
package recipe is used. | ||
|
||
=== `version` | ||
Version of the package to export. If not specified, `version` attribute of the | ||
package recipe is used. | ||
|
||
=== `user` | ||
User (namespace) of the package to export. If not specified | ||
|
||
. `CONAN_USERNAME` environment variable is used, if present; | ||
. or `default_user` attribute of the package recipe is used, if present; | ||
. or the first part of the value of `GITHUB_REPOSITORY` environment variable | ||
(before the slash) is used. | ||
|
||
=== `channel` | ||
Channel of the package to export. If not specified | ||
|
||
. `CONAN_CHANNEL` environment variable is used, if present; | ||
. or `default_channel` attribute of the package recipe is used, if present; | ||
. or the string `testing`. | ||
|
||
=== `reference` | ||
Full reference of the package to export. If specified all inputs that specify | ||
parts of the reference are ignored. | ||
|
||
|
||
== Maintainer | ||
Dmitry Arkhipov <[email protected]> | ||
|
||
|
||
== Contributing | ||
Patches welcome! | ||
|
||
|
||
== License | ||
link:LICENSE[BSL-1.0] (C) 2019 Dmitry Arkhipov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: conan-upload | ||
author: Dmitry Arkhipov <[email protected]> | ||
description: Uploads a package to Conan server | ||
branding: | ||
icon: upload | ||
color: blue | ||
inputs: | ||
login: | ||
description: Username to authenticate as | ||
password: | ||
description: Password to use to authenticate | ||
required: true | ||
url: | ||
description: URL of the Conan remote to upload to | ||
remote: | ||
description: Name of the Conan remote to upload to | ||
name: | ||
description: Package name | ||
version: | ||
description: Package description | ||
channel: | ||
description: Package channel | ||
user: | ||
description: Package user | ||
reference: | ||
description: Full package reference | ||
runs: | ||
using: node12 | ||
main: main.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
const core = require('@actions/core'); | ||
const exec = require('@actions/exec'); | ||
|
||
|
||
function get_env(name) { return (process.env[name] || '').trim(); } | ||
|
||
async function get_output(command, ...args) { | ||
let output = ''; | ||
const opts = { | ||
listeners: { stdout: (data) => { output += data.toString(); } } | ||
}; | ||
await exec.exec(command, args, opts); | ||
|
||
output = output.trim(); | ||
return 'None' != output ? output : '' ; | ||
} | ||
|
||
async function inspect_pkg(attr) { | ||
return await get_output('conan', 'inspect', '.', '--raw', attr); | ||
} | ||
|
||
async function get_input_or_pkg_attr(attr) { | ||
let result = core.getInput(attr); | ||
if (!result) { result = await inspect_pkg(attr); } | ||
return result; | ||
} | ||
|
||
async function get_pkg_user() { | ||
let result = core.getInput('user'); | ||
|
||
if (!result) { result = get_env('CONAN_USERNAME'); } | ||
|
||
if (!result) { result = await inspect_pkg('default_user'); } | ||
|
||
if (!result) { | ||
const repo = get_env('GITHUB_REPOSITORY'); | ||
result = (repo.split('/', 1) || [ '' ])[0].trim(); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
async function get_pkg_channel() { | ||
let result = core.getInput('channel'); | ||
|
||
if (!result) { result = get_env('CONAN_CHANNEL'); } | ||
|
||
if (!result) { result = await inspect_pkg('default_channel'); } | ||
|
||
if (!result) { result = 'testing'; } | ||
|
||
return result; | ||
} | ||
|
||
async function get_pkg_reference() { | ||
let result = core.getInput('reference'); | ||
if (!result) { | ||
const name = await get_input_or_pkg_attr('name'); | ||
const version = await get_input_or_pkg_attr('version'); | ||
const user = await get_pkg_user(); | ||
const channel = await get_pkg_channel(); | ||
result = `${name}/${version}@${user}/${channel}` | ||
} | ||
return result; | ||
} | ||
|
||
async function get_upload_remote() { | ||
let result = {} | ||
|
||
result.name = core.getInput('remote'); | ||
if (!result.name) { result.name = 'upload'; } | ||
|
||
result.url = core.getInput('url'); | ||
if (!result.url) { result.url = get_env('CONAN_UPLOAD'); } | ||
|
||
return result; | ||
} | ||
|
||
async function get_login_username() { | ||
let result = core.getInput('login'); | ||
if (!result) { result = await get_pkg_user(); } | ||
return result; | ||
} | ||
|
||
async function run() { | ||
const remote = await get_upload_remote(); | ||
console.log() | ||
console.log(`Using remote ${remote.name}(${remote.url})`); | ||
exec.exec('conan', ['remote', 'add', remote.name, remote.url]).then( | ||
(resolve) => {}, | ||
(reject) => {}); | ||
|
||
const user = await get_login_username() | ||
const password = core.getInput('password'); | ||
console.log() | ||
console.log(`Authenticating as ${user}`); | ||
await exec.exec('conan', ['user', user, '-r', remote.name, '-p', password]); | ||
|
||
const pkg_reference = await get_pkg_reference(); | ||
console.log() | ||
console.log(`Using full package reference ${pkg_reference}`); | ||
|
||
await exec.exec( | ||
'conan', ['upload', pkg_reference, '-r', remote.name, '--all', '--confirm'] | ||
); | ||
} | ||
|
||
run().then( | ||
(resolve) => {}, | ||
(reject) => { core.setFailed(`Action failed with error ${reject}`); }); |
Oops, something went wrong.