Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

feat add target branch to release creation #2

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
- `FILES`: A glob expression for the list of the files to be uploaded
13 changes: 13 additions & 0 deletions codefresh.yml
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 2 additions & 2 deletions example.yaml
Original file line number Diff line number Diff line change
@@ -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
Binary file added icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions plugin.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,7 +14,7 @@ sources:
maintainers:
- name: Alex Cheshko
email: [email protected]
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
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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