-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
84 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,33 @@ | ||
name: Make release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
sha: | ||
description: "Commit SHA to create release from" | ||
required: true | ||
tag: | ||
description: "Tag of the release" | ||
required: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: github.event.inputs.sha | ||
|
||
- name: Install stable toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
|
||
- name: Build | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --release |
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,48 @@ | ||
import os | ||
|
||
import click | ||
import git | ||
import requests | ||
|
||
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
REPOSITORY = git.Repo(ROOT_DIR) | ||
|
||
|
||
def send_github_event(workflow_name: str, token: str, inputs=()): | ||
if inputs is None: | ||
inputs = {} | ||
payload = {"ref": "ci", "inputs": inputs} | ||
headers = {"Authorization": f"token {token}", | ||
"Accept": "application/vnd.github.v3+json"} | ||
response = requests.post( | ||
f"https://api.github.com/repos/it4innovations/rsds/actions/workflows/{workflow_name}/dispatches", | ||
json=payload, | ||
headers=headers) | ||
response.raise_for_status() | ||
|
||
|
||
token_option = click.option("-t", "--token", required=True, envvar="IR_GITHUB_TOKEN", show_envvar=True, | ||
help="GitHub token. Note, it should have `repo` scope.") | ||
|
||
|
||
@click.command(help="Create a new release") | ||
@click.argument("branch") | ||
@click.argument("tag") | ||
@token_option | ||
def make_release(branch: str, tag: str, token: str): | ||
""" | ||
Create a release using GitHub. | ||
BRANCH is either a branch, commit or SHA from which to create the release. | ||
TAG is the name of the release. | ||
TOKEN is a Github token. | ||
""" | ||
sha = REPOSITORY.rev_parse(branch).hexsha | ||
send_github_event("release.yml", token, { | ||
"sha": sha, | ||
"tag": tag | ||
}) | ||
|
||
|
||
if __name__ == '__main__': | ||
make_release() |
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,3 @@ | ||
click | ||
requests | ||
gitpython |