Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLUG-155: Verify version and autorelease in pipelines #34

Merged
merged 30 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cf68e04
test pipeline command on single branch
artyom-jaksov-tl Oct 1, 2024
f0034a2
try adding action
artyom-jaksov-tl Oct 1, 2024
b8e88af
make name shorter
artyom-jaksov-tl Oct 1, 2024
ec1518f
try different syntax
artyom-jaksov-tl Oct 1, 2024
c09a96a
try more generic utils
artyom-jaksov-tl Oct 1, 2024
893cda3
compare with file from main
artyom-jaksov-tl Oct 1, 2024
7b6a579
fix syntax
artyom-jaksov-tl Oct 1, 2024
0e82373
remove v prefix
artyom-jaksov-tl Oct 1, 2024
436ff05
bump version for testing
artyom-jaksov-tl Oct 2, 2024
c0f286b
test new script
artyom-jaksov-tl Oct 2, 2024
fafefd2
try different syntax
artyom-jaksov-tl Oct 2, 2024
d0d7daf
try with fetch depth
artyom-jaksov-tl Oct 2, 2024
ad24931
try with adding HEAD
artyom-jaksov-tl Oct 2, 2024
9f5650c
try to check out head
artyom-jaksov-tl Oct 2, 2024
8b8e526
try with origin
artyom-jaksov-tl Oct 2, 2024
5c418b4
show versions in pipeline just to be sure
artyom-jaksov-tl Oct 2, 2024
aef5319
revert version, pipeline should fail
artyom-jaksov-tl Oct 2, 2024
83b0afe
get only first and last modification
artyom-jaksov-tl Oct 2, 2024
d05f8db
trigger workflow on pull request
artyom-jaksov-tl Oct 3, 2024
d6eab02
add version compare
artyom-jaksov-tl Oct 7, 2024
102b2bc
create tag and release when pushing to main
artyom-jaksov-tl Oct 7, 2024
927e68b
print versions earlier
artyom-jaksov-tl Oct 7, 2024
40b4a3f
bump version
artyom-jaksov-tl Oct 7, 2024
0b45a5b
use separate variable for greater version
artyom-jaksov-tl Oct 7, 2024
5e7d946
try to fix echo issue
artyom-jaksov-tl Oct 7, 2024
816c107
remove debug step
artyom-jaksov-tl Oct 7, 2024
f34ae66
dont run workflow on tag
artyom-jaksov-tl Oct 7, 2024
ad865a3
update create tag script
artyom-jaksov-tl Oct 9, 2024
d589d2d
simplify script and check changelog
artyom-jaksov-tl Oct 28, 2024
b88b2b7
Merge branch 'develop' into feature/PLUG-155
stefandanaita Oct 29, 2024
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
52 changes: 52 additions & 0 deletions .github/workflows/check-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Check config.xml version
on:
pull_request:
types: [opened, reopened, synchronize]
branches: [main]

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Set OLD_VERSION from etc/config.xml if merge would modify it
run: |
echo "OLD_VERSION=$(git log origin/main..HEAD --cherry -p -- etc/config.xml | grep '\-.\s*.<version>' | tail -1 | tr -d '\-[:blank:]\n' | sed -e 's/<version>\(.*\)<\/version>/\1/')" >> $GITHUB_ENV

- name: Set NEW_VERSION from etc/config.xml if merge would modify it
run: |
echo "NEW_VERSION=$(git log origin/main..HEAD --cherry -p -- etc/config.xml | grep '\+.\s*.<version>' | head -1 | tr -d '+[:blank:]\n' | sed -e 's/<version>\(.*\)<\/version>/\1/')" >> $GITHUB_ENV

- name: Test that versions are not empty
run: |
[[ ! -z $OLD_VERSION ]] && [[ ! -z $NEW_VERSION ]]

- name: Test that versions are different
run: |
[[ $OLD_VERSION != $NEW_VERSION ]]

- name: Test that version string mathches pattern
run: |
[[ $NEW_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]$ ]]

- name: Sort versions
run: |
if [[ $OLD_VERSION =~ ^[0-9]+(\.[0-9]+)+\.[0-9]$ ]]; then
echo "GREATER_VERSION=$(echo -e ${OLD_VERSION}\\n${NEW_VERSION} | sort --version-sort | tail -n1)" >> $GITHUB_ENV
else
echo "GREATER_VERSION=$NEW_VERSION" >> $GITHUB_ENV
fi

- name: Make sure new version is greater
run: |
[[ $GREATER_VERSION == $NEW_VERSION ]]

- name: Ensure changelog is not empty for the new version
run: |
CHANGELOG=$(sed -n "/^## \[v$NEW_VERSION\]/,/^## \[v/p" CHANGELOG.md | sed -e "s/^## \[v.*\$//" | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba')
[[ -n $CHANGELOG ]]
[[ $CHANGELOG == *"### Added"* || $CHANGELOG == *"### Changed"* || $CHANGELOG == *"### Fixed"* ]]
69 changes: 69 additions & 0 deletions .github/workflows/create-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Create Tag

on:
push:
branches:
- main
tags-ignore:
- '**'

jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'

- name: Generate Git Tag
id: generate_tag
run: |
NEW_TAG=v$(cat etc/config.xml | grep '<version>' | tr -d '\-[:blank:]\n' | sed -e 's/<version>\(.*\)<\/version>/\1/')
echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_OUTPUT

- name: Test that version string mathches pattern
run: |
[[ $NEW_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]$ ]]

- name: Test for tag collision
run: |
TAG_EXISTS=0
for EXISTING_TAG in `git tag -l`; do
if [[ $EXISTING_TAG == $NEW_TAG || v$EXISTING_TAG == $NEW_TAG ]]; then
TAG_EXISTS=1
break
fi
done
[[ $TAG_EXISTS == 0 ]]

- name: Ensure changelog is not empty for the new tag
run: |
CHANGELOG=$(sed -n "/^## \[$NEW_TAG\]/,/^## \[v/p" CHANGELOG.md | sed -e "s/^## \[v.*\$//" | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba')
[[ -n $CHANGELOG ]]
[[ $CHANGELOG == *"### Added"* || $CHANGELOG == *"### Changed"* || $CHANGELOG == *"### Fixed"* ]]
- name: Push Git Tag
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git tag $NEW_TAG
git push origin $NEW_TAG

- name: Create changelog diff
run: |
sed -n "/^## \[$NEW_TAG\]/,/^## \[v/p" CHANGELOG.md | sed -e "s/^## \[v.*\$//" | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba' > release_notes.md

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.generate_tag.outputs.NEW_TAG }}
release_name: ${{ steps.generate_tag.outputs.NEW_TAG }}
body_path: ./release_notes.md
draft: false
prerelease: false

- name: Delete release_notes file
run: rm release_notes.md
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<default>
<payment>
<truelayer>
<version>2.3.0</version>
<version>2.3.1</version>
<model>TrueLayerFacade</model>
<title>TrueLayer</title>
<description>Make a direct payment securely from your bank app - no card needed</description>
Expand Down
Loading