🔖 release v1.2.4 #20
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: Publish package | |
on: | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+*' # tag pattern on pub.dev: 'v' | |
defaults: | |
run: | |
shell: bash | |
env: | |
PUB_ENVIRONMENT: bot.github | |
permissions: read-all | |
jobs: | |
test: | |
uses: ./.github/workflows/test.yml | |
secrets: inherit | |
publish: | |
needs: test | |
name: "Publish" | |
permissions: | |
id-token: write | |
runs-on: ubuntu-latest | |
environment: pub.dev | |
steps: | |
- uses: dart-lang/setup-dart@v1 | |
with: | |
sdk: stable | |
- id: checkout | |
uses: actions/checkout@v4 | |
- name: Compare version with ref/tag | |
id: compare_version_with_tag | |
run: | | |
set -e | |
VERSION=$(awk '/^version: / {print $2}' pubspec.yaml) | |
TAG=${GITHUB_REF_NAME#v} | |
if [[ "$VERSION" != "$TAG" ]]; then | |
echo "Version in pubspec.yaml ($VERSION) does not match tag ($TAG)" | |
exit 1 | |
fi | |
- name: Check CHANGELOG.md | |
id: check_changelog | |
run: | | |
set -e | |
if ! grep -q "## $VERSION" CHANGELOG.md; then | |
echo "CHANGELOG.md does not contain a section for $VERSION" | |
exit 1 | |
fi | |
- name: Validate pub.dev topics | |
id: validate_pub_dev_topics | |
run: | | |
set -e | |
pattern="^[a-z][a-z0-9-]*[a-z0-9]$" | |
for topic in $(yq -r '.topics[]' pubspec.yaml); do | |
if [[ ! $topic =~ $pattern ]]; then | |
echo "Invalid topic: $topic" | |
exit 1 | |
fi | |
done | |
- name: Install dependencies | |
run: dart pub get | |
- name: Publish | |
id: publish | |
run: dart pub publish --force | |
release: | |
needs: [ test, publish ] | |
name: "Release" | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get version from pubspec.yaml | |
id: get_version_and_name | |
run: | | |
set -e | |
VERSION=$(awk '/^version: / {print $2}' pubspec.yaml) | |
NAME=$(awk '/^name: / {print $2}' pubspec.yaml) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "NAME=$NAME" >> $GITHUB_ENV | |
- name: Create tag-specific CHANGELOG | |
id: create_changelog | |
run: | | |
set -e | |
CHANGELOG_PATH=$RUNNER_TEMP/CHANGELOG.md | |
awk '/^##[[:space:]].*/ { if (count == 1) exit; count++; print } count == 1 && !/^##[[:space:]].*/ { print }' CHANGELOG.md | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' > $CHANGELOG_PATH | |
echo -en "\n[https://pub.dev/packages/$NAME/versions/$VERSION](https://pub.dev/packages/$NAME/versions/$VERSION)" >> $CHANGELOG_PATH | |
echo "CHANGELOG_PATH=$CHANGELOG_PATH" >> $GITHUB_ENV | |
- name: Create release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: ${{ env.VERSION }} | |
tag_name: v${{ env.VERSION }} | |
body_path: ${{ env.CHANGELOG_PATH }} | |
- name: Clean up | |
id: clean_up | |
if: ${{ always() }} | |
run: | | |
rm -rf $CHANGELOG_PATH | |
docs: | |
uses: ./.github/workflows/docs.yml | |
needs: [ test, publish ] | |
permissions: | |
contents: write | |
secrets: inherit |