Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Comment thread
ryonakano marked this conversation as resolved.
Resolved

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:
Expand Down Expand Up @@ -92,4 +110,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_branch: 'juno'
packaging_branch: 'deb-packaging-juno'
base_branch: '5.x'
```
10 changes: 10 additions & 0 deletions release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
30 changes: 20 additions & 10 deletions release/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -143,29 +156,26 @@ 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"
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
Expand Down