Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Release

# Pushing a tag like v0.2.0 creates its GitHub release, with that version's CHANGELOG.md section as
# the notes. Run it by hand (Actions → Release → Run workflow) for a tag that was pushed before
# this workflow existed. Packagist picks up tags on its own; this only adds the GitHub release.

on:
push:
tags: [ "v*" ]
workflow_dispatch:
inputs:
tag:
description: Existing tag to create a release for, e.g. v0.1.0
required: true

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}

- name: Release notes from CHANGELOG.md
env:
TAG: ${{ inputs.tag || github.ref_name }}
run: |
version="${TAG#v}"
# The lines between "## [<version>]" and the next "## [" heading
awk -v v="$version" '
index($0, "## [" v "]") == 1 { found = 1; next }
found && /^## \[/ { exit }
found { print }
' CHANGELOG.md > notes.md
if [ ! -s notes.md ]; then
echo "::error::CHANGELOG.md has no section for ${version}"
exit 1
fi

- name: Create the GitHub release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag || github.ref_name }}
run: |
# Tags with a suffix (v1.0.0-rc.1) are pre-releases, like Composer treats them
prerelease=""
case "$TAG" in *-*) prerelease="--prerelease" ;; esac
gh release create "$TAG" --title "Mygra ${TAG}" --notes-file notes.md --verify-tag $prerelease
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ composer analyse # PHPStan, level 6

`composer.lock` is committed and resolved for PHP 8.1 (`config.platform.php`), so every CI job installs the same versions. After changing dependencies, run `composer update` and commit the lock file.

## Releasing

1. Move the changes under a new `## [x.y.z] - YYYY-MM-DD` heading in `CHANGELOG.md` (and add its link at the bottom). Merge to `main` with CI green.
2. Tag and push: `git tag -a vx.y.z -m "Mygra x.y.z" && git push origin vx.y.z`.

Packagist publishes the tag on its own, and the Release workflow creates the GitHub release with that version's CHANGELOG section as its notes. A tag with a suffix (`v1.0.0-rc.1`) becomes a pre-release.

## License

By contributing to this project, you agree to license your contribution under the MIT license.
Loading