diff --git a/release/README.md b/release/README.md index 651c1f2..ba0e578 100644 --- a/release/README.md +++ b/release/README.md @@ -7,7 +7,7 @@ For more information on the overall flow of this ci image, take a look at the [e This image is intended for use with elementary debian projects. There are a few requirements before getting started: - 1. The project needs to have a deb-packaging branch with the necessary debian packaging for the project. + 1. The project needs to have a branch with the necessary debian packaging for the project, typically named as `deb-packaging`. 2. The project needs release information in an `appdata.xml` file. Docs: [appdata](https://docs.elementary.io/develop/writing-apps/our-first-app/metadata) ### Environment Variables @@ -30,6 +30,24 @@ with: release_branch: 'juno' ``` +### Specifying a packaging branch name + +By default, this action will update the `changelog` file in a branch named 'deb-packaging' whenever a release is pushed. The branch name can be set via the `packaging_branch` input. Example: + +```yaml +with: + packaging_branch: 'deb-packaging-juno' +``` + +### Specifying a base branch name + +By default, this action will use the current branch where the workflow action exists as a base branch of the release branch. The branch name can be set via the `base_branch` input. Example: + +```yaml +with: + base_branch: 'develop' +``` + ### Specifying a label By default, the examples check for a label called `Release` on the related pull request. This can be set in the workflow action by changing the following: @@ -92,4 +110,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: release_branch: 'juno' + packaging_branch: 'deb-packaging-juno' + base_branch: '5.x' ``` diff --git a/release/action.yml b/release/action.yml index e222056..509d89c 100644 --- a/release/action.yml +++ b/release/action.yml @@ -5,11 +5,21 @@ inputs: description: 'the name of the stable release branch' required: false default: 'stable' + packaging_branch: + description: 'the name of the Debian packaging branch' + required: false + default: 'deb-packaging' + base_branch: + description: 'the name of the base branch or use the current branch where the workflow action exists if unspecified' + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' args: - ${{ inputs.release_branch }} + - ${{ inputs.packaging_branch }} + - ${{ inputs.base_branch }} branding: icon: 'git-pull-request' color: 'green' diff --git a/release/entrypoint.sh b/release/entrypoint.sh index 0f01bc9..bf8eb31 100755 --- a/release/entrypoint.sh +++ b/release/entrypoint.sh @@ -22,6 +22,19 @@ if [ -z "$1" ]; then else RELEASE_BRANCH="$1" fi + +if [ -z "$2" ]; then + PACKAGING_BRANCH="deb-packaging" +else + PACKAGING_BRANCH="$2" +fi + +if [ -z "$3" ]; then + BASE_BRANCH="$(git branch --show-current)" +else + BASE_BRANCH="$3" +fi + # default email and username to github actions user if [ -z "$GIT_USER_EMAIL" ]; then GIT_USER_EMAIL="action@github.com" @@ -110,8 +123,8 @@ echo "Debian Changelog Content:" echo -e "$FILTERED_COMMITS\n" # move to the debian packaging branch -if ! git checkout deb-packaging; then - echo "\033[0;31mERROR: Unable to checkout the 'deb-packaging' branch. Does it exist?\033[0m" && exit 1 +if ! git checkout "$PACKAGING_BRANCH"; then + echo "\033[0;31mERROR: Unable to checkout the '$PACKAGING_BRANCH' branch. Does it exist?\033[0m" && exit 1 fi if [ -z "$FILTERED_COMMITS" ]; then @@ -143,19 +156,16 @@ fi if ! (git push && git push origin "$TAG"); then echo "\033[0;31mERROR: Unable to push changelog information!\033[0m" && exit 1 fi -echo -e "\n\033[1;32mChangelogs have been pushed to deb-packaging!\033[0m\n" +echo -e "\n\033[1;32mChangelogs have been pushed to $PACKAGING_BRANCH!\033[0m\n" #------------------# # Deploy to stable # #------------------# -# point head back to what it was before checking out deb-packaging +# point head back to what it was before checking out the packaging branch git checkout - git reset --hard HEAD -# get default branch, see: https://davidwalsh.name/get-default-branch-name -DEFAULT_BRANCH="$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)" - # checkout or create stable branch if ! git show-ref --verify --quiet refs/heads/"$RELEASE_BRANCH"; then git checkout -b "$RELEASE_BRANCH" @@ -163,9 +173,9 @@ else git checkout "$RELEASE_BRANCH" fi -# rebase off of default branch & push to remote -if ! git rebase origin/"$DEFAULT_BRANCH"; then - echo "\033[0;31mERROR: Unable to merge default branch $DEFAULT_BRANCH into $RELEASE_BRANCH!\033[0m" && exit 1 +# rebase off of base branch & push to remote +if ! git rebase origin/"$BASE_BRANCH"; then + echo "\033[0;31mERROR: Unable to merge base branch $BASE_BRANCH into $RELEASE_BRANCH!\033[0m" && exit 1 fi if ! git push origin "$RELEASE_BRANCH" --force-with-lease; then echo "\033[0;31mERROR: Unable to push changes to the $RELEASE_BRANCH branch!\033[0m" && exit 1