Skip to content

Add v3 fields

Add v3 fields #134

Workflow file for this run

name: Post-merge
on:
pull_request_target:
branches:
- master
types: [closed]
jobs:
changelog-entry:
if: github.event.pull_request.merged && github.repository_owner == 'entur' && !contains(github.event.pull_request.labels.*.name, 'skip changelog')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git user
run: |
git config --global user.name 'Lamassu Changelog Bot'
git config --global user.email '[email protected]'
- name: Generate changelog entry from PR information
run: |
# add a line above the one which contains AUTOMATIC_CHANGELOG_PLACEHOLDER
ITEM="${TITLE} [#${NUMBER}](${URL})"
TEMP_FILE=Changelog.generated.md
FILE=Changelog.md
awk "/CHANGELOG_PLACEHOLDER/{print \"- $ITEM\"}1" $FILE > $TEMP_FILE
mv $TEMP_FILE $FILE
git add $FILE
git commit -m "Add changelog entry for #${NUMBER} [ci skip]"
git pull --rebase origin master
git push ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git HEAD:master
env:
# Use environment variables to prevent injection attack
TITLE: ${{ github.event.pull_request.title }}
NUMBER: ${{ github.event.pull_request.number }}
URL: ${{ github.event.pull_request.html_url }}
serialization-version:
# if you have a dependent job that is skipped (i.e. you want to bump the version but not have a changelog entry) you must add
# always() before your actual condition you want for the job
# https://github.com/actions/runner/issues/491#issuecomment-660122693
if: always() && github.event.pull_request.merged && github.repository_owner == 'entur' && contains(github.event.pull_request.labels.*.name, 'bump serialization id')
runs-on: ubuntu-latest
needs: [changelog-entry]
permissions:
contents: write
steps:
- name: Install xmllint
run: |
sudo apt-get install -y libxml2-utils
- name: Configure git user
run: |
git config --global user.name 'Lamassu Serialization Version Bot'
git config --global user.email '[email protected]'
- name: Checkout
uses: actions/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Bump serialization version
run: |
version=`xmllint --xpath "//*[local-name()='lamassu.serialization.version.id']/text()" pom.xml`
bumped=$((version+1))
sed -Ei "s/<lamassu\.serialization\.version\.id>.*<\/lamassu\.serialization\.version\.id>/<lamassu\.serialization\.version\.id>${bumped}<\/lamassu\.serialization\.version\.id>/" pom.xml
git add pom.xml
git commit -m "Bump serialization version id for #${NUMBER}"
# just for safety as the Github repo is eventually consistent, therefore this push competes with the changelog entry one
git pull --rebase origin master
git push ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git HEAD:master
env:
# Use environment variables to prevent injection attack
NUMBER: ${{ github.event.pull_request.number }}