LAN-164 - Add automated releases #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Prepare Release | |
on: | |
workflow_dispatch: | |
# TODO: Remove when PR ready | |
pull_request: | |
jobs: | |
prepare_release: | |
runs-on: ubuntu-latest | |
steps: | |
# Disabled for testing purposes | |
#- uses: octo-sts/action@main | |
# id: octo-sts | |
# with: | |
# scope: shopware/SwagLanguagePack | |
# identity: release | |
- uses: actions/checkout@v4 | |
with: | |
# token: ${{ steps.octo-sts.outputs.token }} | |
fetch-depth: 0 | |
- name: Check for changes | |
shell: bash | |
id: check-changes | |
run: | | |
if [[ -z $(git diff HEAD $(git describe --tags $(git rev-list --tags --max-count=1)) src/) ]]; then | |
echo "No changes detected" | |
echo "no_changes=1" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Increase version | |
shell: bash | |
if: ${{ ! steps.check-changes.outputs.no_changes }} | |
run: | | |
version=$(jq -r '.version' composer.json) | |
regex="([0-9]+).([0-9]+).([0-9]+)" | |
if [[ $version =~ $regex ]]; then | |
major="${BASH_REMATCH[1]}" | |
minor="${BASH_REMATCH[2]}" | |
fi | |
new_version="${major}.$((minor+1)).0" | |
jq --arg version "$new_version" --indent 4 '.version = $version' composer.json > composer.json.tmp | |
mv composer.json.tmp composer.json | |
composer validate | |
echo "Old version: ${version}" | |
echo "New version: $(jq '.version' composer.json)" | |
- name: Push new version | |
if: ${{ ! steps.check-changes.outputs.no_changes }} | |
shell: bash | |
run: | | |
git config user.name shopwareBot | |
git config user.email development@shopware.com | |
git add . | |
git commit -m "Prepare release $(jq -r '.version' composer.json)" | |
git diff HEAD~1 HEAD | |
# git push | |
# Disabled for testing purposes | |
# release: | |
# needs: prepare_release | |
# uses: shopware/SwagLanguagePack/.github/workflows/store-release.yml@master |