Skip to content

Commit

Permalink
Merge pull request #139 from diffblue/thomas/AutomateReleases
Browse files Browse the repository at this point in the history
[TG-21107] Automate releases
  • Loading branch information
ThomasPerkins1123 authored Apr 19, 2024
2 parents 4d5f9be + 90cc544 commit 2eac32f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

REPO="diffblue/cover-github-action"
BRANCH_NAME="release/$1"
PR_TITLE="Release $1"
PR_BODY="Update Diffblue Cover to $1"

git checkout -b "$BRANCH_NAME"

sed -i "s/cli:[0-9]\{4\}\.[0-9]\{2\}\.[0-9]\{2\}-jdk/cli:$1-jdk/g" Dockerfile

./build.sh
git add Dockerfile
git add */Dockerfile
git commit -m "Bump docker image to $1"

git push origin "$BRANCH_NAME"

curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
-d '{"title": "'"$PR_TITLE"'", "body": "'"$PR_BODY"'", "head": "'"$BRANCH_NAME"'", "base": "main"}' \
"https://api.github.com/repos/$REPO/pulls"
24 changes: 24 additions & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Create release

on:
push:
branches:
- main

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Create release
if: contains(github.event.head_commit.message, '/release/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION_NUMBER=$(echo "${{github.event.head_commit.message}}" | sed -n 's/.*release\/\([0-9]\{4\}\.[0-9]\{2\}\.[0-9]\{2\}\).*/\1/p')
if [ -n "$VERSION_NUMBER" ]; then
gh release create "v$VERSION_NUMBER" --repo="$GITHUB_REPOSITORY" --title="v$VERSION_NUMBER" --generate-notes
else
echo "Could not get version number from commit name: ${{github.event.head_commit.message}}"
exit 1
fi

0 comments on commit 2eac32f

Please sign in to comment.