Skip to content

ci: fix releaserc (#7262) #40

ci: fix releaserc (#7262)

ci: fix releaserc (#7262) #40

Workflow file for this run

name: Release
on:
pull_request:
branches-ignore: ['*']
push:
branches:
- next
- next-major
- beta
- alpha
- 4.x
workflow_dispatch:
env:
php-version: '8.2'
build-node-version: 20
semantic-node-version: 20
jobs:
####################
# Semantic release
####################
semantic:
runs-on: ubuntu-latest
name: Semantic release
if: github.event_name != 'pull_request'
outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Get all tags
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.semantic-node-version }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN_RELEASE: ${{ secrets.GH_TOKEN_RELEASE }}
with:
semantic_version: 23
extra_plugins: |
conventional-changelog-conventionalcommits@7
@semantic-release/changelog@6
- name: New release published
if: steps.semantic.outputs.new_release_published == 'true'
run: echo "### Release ${{ steps.semantic.outputs.new_release_version }} created :rocket:" >> $GITHUB_STEP_SUMMARY
- name: Store changelog file
if: steps.semantic.outputs.new_release_published == 'true'
uses: actions/upload-artifact@v3
with:
name: changelog
path: CHANGELOG.md
package:
needs: semantic
runs-on: ubuntu-latest
name: Package release
if: needs.semantic.outputs.new_release_published == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: v${{ needs.semantic.outputs.new_release_version }}
- name: Download changelog file
uses: actions/download-artifact@v3
with:
name: changelog
- name: Setup PHP ${{ env.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php-version }}
extensions: redis
coverage: none
# Composer
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer files
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ env.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ env.php-version }}-${{ hashFiles('**/composer.lock') }}
${{ runner.os }}-composer-${{ env.php-version }}
${{ runner.os }}-composer-
# Yarn
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.build-node-version }}
- name: Get yarn cache directory path
id: yarn-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache yarn files
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
${{ runner.os }}-yarn-
- name: Import key
run: echo -e "$GPG_KEY" | gpg --batch --yes --import -
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
- name: Create package
id: package
run: scripts/ci/package.sh 'v${{ needs.semantic.outputs.new_release_version }}' $GITHUB_SHA
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
- name: Publish package
run: |
for f in {${{ steps.package.outputs.package }},${{ steps.package.outputs.assets }}}{,.asc,.sha512,.sha512.asc}; do
echo "Uploading release file '$f'..."
gh release upload 'v${{ needs.semantic.outputs.new_release_version }}' "$f" --clobber
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Store package
uses: actions/upload-artifact@v3
with:
name: package
path: ${{ steps.package.outputs.package }}
- name: Store assets
uses: actions/upload-artifact@v3
with:
name: assets
path: ${{ steps.package.outputs.assets }}
docker-workflow:
needs: [semantic, package]
runs-on: ubuntu-latest
name: Docker release create
if: needs.semantic.outputs.new_release_published == 'true'
steps:
- name: Dispatch docker release
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Release update
repo: monicahq/docker
token: ${{ secrets.DOCKER_GITHUB_TOKEN }}