Skip to content

Commit 2ac9f4e

Browse files
authored
Add two more GitHub Actions workflows (libgit2#633)
This change adds: * `tag.yml`: Creates a new tag every time the master or a release branch is pushed. * `backport.yml`: Creates a cherry-pick in older release branches to keep them up to date with little cost.
1 parent 5314951 commit 2ac9f4e

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

.github/workflows/backport.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Backport to older releases
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
jobs:
8+
9+
backport:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
branch: [ 'release-0.28', 'release-0.27' ]
14+
name: Backport change to branch ${{ matrix.branch }}
15+
16+
runs-on: ubuntu-20.04
17+
18+
steps:
19+
- name: Check out code
20+
uses: actions/checkout@v1
21+
with:
22+
fetch-depth: 0
23+
- name: Create a cherry-pick PR
24+
run: |
25+
if ! git diff --quiet HEAD^ HEAD -- vendor/libgit2; then
26+
echo '::warning::Skipping cherry-pick since it is a vendored libgit2 bump'
27+
exit 0
28+
fi
29+
30+
BRANCH_NAME="cherry-pick-${{ github.run_id }}-${{ matrix.branch }}"
31+
32+
# Setup usernames and authentication
33+
git config --global user.name "${{ github.actor }}"
34+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
35+
cat <<- EOF > $HOME/.netrc
36+
machine github.com
37+
login ${{ github.actor }}
38+
password ${{ secrets.GITHUB_TOKEN }}
39+
machine api.github.com
40+
login ${{ github.actor }}
41+
password ${{ secrets.GITHUB_TOKEN }}
42+
EOF
43+
chmod 600 $HOME/.netrc
44+
45+
# Create the cherry-pick commit and create the PR for it.
46+
git checkout "${{ matrix.branch }}"
47+
git switch -c "${BRANCH_NAME}"
48+
git cherry-pick -x "${{ github.sha }}"
49+
git push --set-upstream origin "${BRANCH_NAME}"
50+
GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" gh pr create \
51+
--base "${{ matrix.branch }}" \
52+
--title "$(git --no-pager show --format="%s" --no-patch HEAD)" \
53+
--body "$(git --no-pager show --format="%b" --no-patch HEAD)"

.github/workflows/tag.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Tag new releases
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- release-*
7+
8+
jobs:
9+
10+
tag-release:
11+
name: Bump tag in ${{ github.ref }}
12+
13+
runs-on: ubuntu-20.04
14+
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v1
18+
with:
19+
fetch-depth: 0
20+
- name: Bump version and push tag
21+
id: bump-version
22+
uses: anothrNick/github-tag-action@9aaabdb5e989894e95288328d8b17a6347217ae3
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
WITH_V: true
26+
DEFAULT_BUMP: patch
27+
TAG_CONTEXT: branch
28+
RELEASE_BRANCHES: .*

0 commit comments

Comments
 (0)