-
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: Thu Oct 10 10:11:17 UTC 2019 942e689
- Loading branch information
0 parents
commit ed948db
Showing
27 changed files
with
1,695 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,91 @@ | ||
= 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, the current git ref name | ||
is matched against _stable pattern_. If matches, the _stable channel_ is used, | ||
otherwise the _testing channel_ is used. | ||
|
||
Stable pattern comes from environment variable `CONAN_STABLE_BRANCH_PATTERN` | ||
if it's present, otherwise it is `++^(master$|release.*|stable.*)++`. | ||
|
||
Stable channel comes from environment variable `CONAN_STABLE_CHANNEL` if it's | ||
present, otherwise it is the string `stable`. | ||
|
||
Testing channel is either | ||
|
||
. the value of environment variable `CONAN_CHANNEL` if it's present; | ||
. or `default_user` attribute of the package recipe, if it's 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,123 @@ | ||
const core = require('@actions/core'); | ||
const exec = require('@actions/exec'); | ||
|
||
|
||
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 = (process.env['CONAN_USERNAME'] || '').trim(); } | ||
|
||
if (!result) { result = await inspect_pkg('default_user'); } | ||
|
||
if (!result) { | ||
const repo = process.env['GITHUB_REPOSITORY'] || ''; | ||
result = (repo.split('/', 1) || [''])[0].trim(); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
|
||
async function get_pkg_channel() { | ||
let result = core.getInput('channel'); | ||
|
||
if (!result) { | ||
const stable_channel | ||
= (process.env['CONAN_STABLE_CHANNEL'] || '').trim() | ||
|| 'stable'; | ||
const testing_channel | ||
= (process.env['CONAN_CHANNEL'] || '').trim() | ||
|| (await inspect_pkg('default_channel')) | ||
|| 'testing'; | ||
|
||
const git_ref = process.env['GITHUB_REF'].split('/', 3)[2].trim(); | ||
const stable_pattern | ||
= (process.env['CONAN_STABLE_BRANCH_PATTERN'] || '').trim() | ||
|| '^(master$|release.*|stable.*)'; | ||
|
||
result = git_ref.match(stable_pattern) ? stable_channel : testing_channel; | ||
} | ||
|
||
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 = (process.env['CONAN_UPLOAD'] || '').trim(); } | ||
|
||
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})`); | ||
await exec.exec('conan', ['remote', 'add', remote.name, remote.url]); | ||
|
||
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() |
Oops, something went wrong.