diff --git a/README.md b/README.md index 524a527..0d3d10c 100644 --- a/README.md +++ b/README.md @@ -6,25 +6,26 @@ A quick plugin to cover specific use case: create releases in GitHub and upload This example creates a release and uploads files to it: -``` +``` bash github_prerelease: - image: codefresh/cfstep-github-release - environment: - - GITHUB_TOKEN=${{GITHUB_TOKEN}} - - FILES=bin/app-* - - PRERELEASE=true + image: codefreshplugins/cfstep-github-release + environment: + - GITHUB_TOKEN=${{GITHUB_TOKEN}} + - FILES=bin/app-* + - PRERELEASE=true ``` + ## Advanced usage If one wants to do more actions to manage releases than just to create them, it is possible to override the behaviour with custom commands: -``` -github_prerelease: - image: codefresh/cfstep-github-release - commands: - - github-release edit --user $CF_REPO_OWNER --repo $CF_REPO_NAME --tag $CF_BRANCH_TAG_NORMALIZED --name "$CF_BRANCH_TAG_NORMALIZED" - - github-release delete --user $CF_REPO_OWNER --repo $CF_REPO_NAME --tag $CF_BRANCH_TAG_NORMALIZED - - github-release --help +``` bash +github_release_modify: + image: codefreshplugins/cfstep-github-release + commands: + - github-release edit --user $CF_REPO_OWNER --repo $CF_REPO_NAME --tag $CF_BRANCH_TAG_NORMALIZED --name "$CF_BRANCH_TAG_NORMALIZED" + - github-release delete --user $CF_REPO_OWNER --repo $CF_REPO_NAME --tag $CF_BRANCH_TAG_NORMALIZED + - github-release --help ``` More details about the paramaters and examples see [here](https://github.com/aktau/github-release) @@ -34,6 +35,7 @@ More details about the paramaters and examples see [here](https://github.com/akt - `GITHUB_TOKEN`: token for access to GitHub - `CF_REPO_OWNER`: Codefresh provided variable containing repository owner name - `CF_REPO_NAME`: Codefresh provided variable containing repository name -- `CF_BRANCH_TAG_NORMALIZED`: Codefresh provided variable containing branch/tag name +- `CF_BRANCH_TAG_NORMALIZED`: Codefresh provided variable containing tag name +- `CF_TARGET_BRANCH`: Codefresh provided variable containing target branch (default branch if not set) - `PRERELEASE`: If true, this variable tells the plugin to create a pre-release -- `FILES`: A glob expression for the list of the files to be uploaded \ No newline at end of file +- `FILES`: A glob expression for the list of the files to be uploaded diff --git a/codefresh.yml b/codefresh.yml new file mode 100644 index 0000000..97b47be --- /dev/null +++ b/codefresh.yml @@ -0,0 +1,13 @@ +version: '1.0' +steps: + BuildImage: + title: Building Docker Image + type: build + image_name: codefreshplugins/cfstep-github-release + PushingToRegistry: + type: push + title: Pushing To Registry + candidate: ${{BuildImage}} + tags: + - latest + - "0.1" diff --git a/example.yaml b/example.yaml index d80ad03..8a6c565 100644 --- a/example.yaml +++ b/example.yaml @@ -1,6 +1,6 @@ github_prerelease: - image: codefresh/cfstep-github-release + image: codefreshplugins/cfstep-github-release commands: - - github-release edit --user $CF_REPO_OWNER --repo $CF_REPO_NAME --tag $CF_BRANCH_TAG_NORMALIZED --name "$CF_BRANCH_TAG_NORMALIZED" + - github-release edit --user $CF_REPO_OWNER --repo $CF_REPO_NAME --tag $CF_BRANCH_TAG_NORMALIZED --name "$CF_BRANCH_TAG_NORMALIZED" --target "$CF_TARGET_BRANCH" - github-release delete --user $CF_REPO_OWNER --repo $CF_REPO_NAME --tag $CF_BRANCH_TAG_NORMALIZED - github-release --help \ No newline at end of file diff --git a/icon.jpg b/icon.jpg new file mode 100644 index 0000000..8c163f4 Binary files /dev/null and b/icon.jpg differ diff --git a/plugin.yaml b/plugin.yaml index 20f51ed..c115fc4 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,6 +1,6 @@ -image: docker.io/codefresh/cfstep-github-release +image: codefreshplugins/cfstep-github-release tag: master -version: 0.1.0 +version: 0.2.0 description: Plugin to make github releases keywords: - github @@ -14,7 +14,7 @@ sources: maintainers: - name: Alex Cheshko email: a.cheshko@codefresh.io -icon: A URL to an SVG or PNG image to be used as an icon (optional) +icon: https://raw.githubusercontent.com/codefresh-plugins/cfstep-github-release/master/icon.jpg envs: - name: GITHUB_TOKEN type: required @@ -27,7 +27,10 @@ envs: description: Codefresh provided variable containing repository name - name: CF_BRANCH_TAG_NORMALIZED type: required - description: Codefresh provided variable containing branch/tag name + description: Codefresh provided variable containing tag name + - name: CF_TARGET_BRANCH + type: optional + description: Codefresh provided variable containing target branch - name: PRERELEASE description: If true, this variable tells the plugin to create a pre-release - name: FILES diff --git a/run.sh b/run.sh index 9de7ab9..8270d36 100755 --- a/run.sh +++ b/run.sh @@ -5,13 +5,15 @@ for reqVar in GITHUB_TOKEN CF_REPO_OWNER CF_REPO_NAME CF_BRANCH_TAG_NORMALIZED; if [ -z ${!reqVar} ]; then echo "The variable $reqVar is not set, stopping..."; exit 1; fi done -if [ "$PRERELEASE" = "true" ]; then PRERELEASE="-p"; fi +if [ "$PRERELEASE" = "true" ]; then PRERELEASE="-p"; else PRERELEASE=""; fi +if [ "$CF_TARGET_BRANCH" ]; then CF_TARGET_BRANCH="--target $CF_TARGET_BRANCH"; fi - github-release release --user $CF_REPO_OWNER --repo $CF_REPO_NAME --tag $CF_BRANCH_TAG_NORMALIZED --name "$CF_BRANCH_TAG_NORMALIZED" $PRERELEASE +github-release release --user $CF_REPO_OWNER --repo $CF_REPO_NAME --tag $CF_BRANCH_TAG_NORMALIZED --name $CF_BRANCH_TAG_NORMALIZED $CF_TARGET_BRANCH $PRERELEASE +### upload files .... if [ ! -z "$FILES" ]; then for file in $FILES; do echo "Uploading file $file........" github-release upload --user $CF_REPO_OWNER --repo $CF_REPO_NAME --tag $CF_BRANCH_TAG_NORMALIZED --name $(basename $file) --file $file - done + done fi \ No newline at end of file