improve release #131
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: 'Releasing latest changes' | |
on: | |
push: | |
tags: | |
- '*' | |
env: | |
# 1. for Github split | |
GITHUB_TOKEN: ${{ secrets.ECOTONE_BOT_TOKEN }} | |
jobs: | |
prepare-code-for-release: | |
name: "Auto fix PHP CS and set up required package versions" | |
runs-on: ubuntu-latest | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
steps: | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.2 | |
coverage: none | |
- name: We need to fetch all related branches to perform next action | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
token: ${{ secrets.ECOTONE_BOT_TOKEN }} | |
- name: Ensure ECOTONE_ENTERPRISE_PUBLIC_KEY secret exists | |
run: | | |
if [ -z "${{ secrets.ECOTONE_ENTERPRISE_PUBLIC_KEY }}" ]; then | |
echo "ECOTONE_ENTERPRISE_PUBLIC_KEY secret is missing" | |
exit 1 | |
fi | |
- name: Setup Git | |
run: | | |
git config user.name "Ecotone Framework Bot" | |
git config user.email "ecotoneframework@gmail.com" | |
- name: Checkout branch related to tag | |
run: | | |
raw=$(git branch -r --contains ${{ github.ref }}) | |
branch=${raw##*/} | |
echo "checking out branch $branch for tag ${GITHUB_REF#refs/tags/}" | |
git checkout $branch | |
- name: Install PHP-CS-Fixer | |
run: | | |
composer global require friendsofphp/php-cs-fixer | |
export PATH="$PATH:$HOME/.composer/vendor/bin" | |
- name: Run PHP CS Fixer | |
run: php-cs-fixer fix --config=.php-cs-fixer.dist.php --allow-risky=yes | |
- name: Run Update Required Packages | |
run: php bin/update-required-packages.php ${{ github.ref_name }} | |
- name: Commit changes | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Release ${{ github.ref_name }} | |
get_packages: | |
name: Package splitting | |
needs: prepare-code-for-release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set Up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.2 | |
coverage: none | |
- uses: actions/checkout@v2 | |
- name: Get Packages | |
id: get_json | |
run: echo "::set-output name=json::$(bin/get-packages)" | |
- name: Output Packages | |
run: echo "${{ steps.get_json.outputs.json }}" | |
outputs: | |
matrix: ${{ steps.get_json.outputs.json }} | |
split_packages: | |
name: Split Package ${{ matrix.package.name }} | |
needs: get_packages | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
package: ${{ fromJson(needs.get_packages.outputs.matrix) }} | |
steps: | |
# We need to check out what we've committed in prepare-code-for-release | |
- name: We need to fetch all related branches to perform next action | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: Checkout branch related to tag | |
run: | | |
raw=$(git branch -r --contains ${{ github.ref }}) | |
branch=${raw##*/} | |
echo "checking out branch $branch for tag ${GITHUB_REF#refs/tags/}" | |
git checkout $branch | |
- name: Replace key.pem with ECOTONE_ENTERPRISE_PUBLIC_KEY | |
if: ${{ matrix.package.name == 'ecotone' }} | |
run: | | |
echo "${{ secrets.ECOTONE_ENTERPRISE_PUBLIC_KEY }}" > ${{ matrix.package.directory }}/src/Messaging/Config/Licence/key.pem | |
- | |
uses: "danharrin/monorepo-split-github-action@v2.3.0" | |
if: "startsWith(github.ref, 'refs/tags/')" | |
with: | |
tag: ${GITHUB_REF#refs/tags/} | |
# ↓ split "packages/easy-coding-standard" directory | |
package_directory: '${{ matrix.package.directory }}' | |
# ↓ into https://github.com/symplify/easy-coding-standard repository | |
repository_organization: '${{ matrix.package.organisation }}' | |
repository_name: '${{ matrix.package.repository }}' | |
# ↓ the user signed under the split commit | |
user_name: "Ecotone FrameworkBot" | |
user_email: "ecotoneframework@gmail.com" | |
tweet: | |
runs-on: ubuntu-latest | |
needs: split_packages | |
steps: | |
- uses: Eomm/why-don-t-you-tweet@v1 | |
with: | |
tweet-message: New Ecotone version was released ${{ github.ref_name }}. Check the changelog on https://github.com/ecotoneframework/ecotone-dev/releases/tag/${{ github.ref_name }} | |
env: | |
# Get your tokens from https://developer.twitter.com/apps | |
TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }} | |
TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} | |
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} | |
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} | |