Skip to content

Commit

Permalink
Add everything
Browse files Browse the repository at this point in the history
  • Loading branch information
Lau Skorstengaard committed Dec 9, 2021
1 parent 4cafb43 commit c5e7653
Show file tree
Hide file tree
Showing 343 changed files with 76,903 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Toitware

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
# pkg-publish
GitHub action for publishing a package

## Setup
To set up publishing for a package repository add the following to `./github/workflows/publish.yml`:
```
name: Publish package
on:
push:
tags:
- 'v*'
jobs:
create-release:
name: Create new release
runs-on: ubuntu-latest
steps:
- name: Publish
uses: toitlang/pkg-publish@v1
```
13 changes: 13 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Toit pkg publish
description: Publish a Toit package to the package registry
author: Toitware APS
inputs:
tag:
description: The tag to publish to.
required: false
repository:
description: The repository with the package.
required: false
runs:
using: 'node12'
main: 'index.js'
66 changes: 66 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const core = require('@actions/core');
const github = require('@actions/github');
const https = require('https')

try {
const input_options = {
required: true,
trimWhitespace: true,
};

const owner = github.context.repo.owner;
const repo = github.context.repo.repo;

let tag = core.getInput('tag');
if (tag === "") {
const ref = github.context.ref
tag = ref.substr(ref.lastIndexOf('/') + 1)
console.log(`No tag given, using '${tag}'.`);
}

let repository = core.getInput('repository');
if (repository === "") {
const owner = github.context.repo.owner;
const repo = github.context.repo.repo;
repository = `${owner}/${repo}`
console.log(`No repository given, using '${repository}'.`)
}

let request_call = new Promise((resolve, reject) => {
const options = {
hostname: 'pkg.toit.io',
port: 443,
path: `/api/v1/register/github.com/${repository}/version/${tag}`,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': 0
}
}

const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`)

res.on('error', error => {
reject(error);
});
resolve(res);
});

req.on('error', error => {
reject(error)
});

req.end();
});

request_call.then((response) => {
console.log(response);
}).catch((error) => {
console.log(error);
core.setFailed(error.message);
});

} catch (error) {
core.setFailed(error.message);
}
210 changes: 210 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions node_modules/@actions/core/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c5e7653

Please sign in to comment.