Skip to content

fix: and now register their own #5

fix: and now register their own

fix: and now register their own #5

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: main
submodules: recursive
- uses: subosito/flutter-action@v2
with:
channel: stable
- name: Install system deps
run: |
sudo apt-get update -q
sudo apt-get install -y cmake clang
- name: Install dependencies
run: dart pub get
- name: Build native library
run: dart run bin/build_native.dart
- name: Run tests
run: dart test
prepare:
name: Prepare release
needs: test
runs-on: ubuntu-latest
permissions:
contents: write # push version bump commit
outputs:
tag: ${{ steps.meta.outputs.tag }}
version: ${{ steps.meta.outputs.version }}
prerelease: ${{ steps.meta.outputs.prerelease }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
ref: main
- uses: subosito/flutter-action@v2
with:
channel: stable
- name: Install dependencies
run: dart pub get
- name: Extract version and detect pre-release
id: meta
run: |
TAG="${{ github.ref_name }}"
VERSION="${TAG#v}"
if [[ "$TAG" =~ (alpha|beta|rc) ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Bump version in pubspec.yaml
run: |
VERSION="${{ steps.meta.outputs.version }}"
sed -i "s/^version: .*/version: $VERSION/" pubspec.yaml
grep '^version:' pubspec.yaml
- name: Commit and push version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add pubspec.yaml
git diff --cached --quiet || git commit -m "chore: bump version to ${{ steps.meta.outputs.version }}"
git push origin main
- name: Extract release notes from CHANGELOG
run: |
VERSION="${{ steps.meta.outputs.version }}"
awk "/^## \[$VERSION\]/{found=1; next} /^## \[/{if(found) exit} found{print}" \
CHANGELOG.md > /tmp/release_notes.md
if [ ! -s /tmp/release_notes.md ]; then
echo "No changelog entry found for $VERSION — add it to CHANGELOG.md first"
exit 1
fi
cat /tmp/release_notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.meta.outputs.tag }}
body_path: /tmp/release_notes.md
prerelease: ${{ steps.meta.outputs.prerelease }}
publish:
name: Publish to pub.dev
needs: prepare
runs-on: ubuntu-latest
permissions:
id-token: write # pub.dev OIDC trusted publisher
steps:
# `main` at this point already has the version bump `prepare` pushed —
# the pushed tag itself still points at the pre-bump commit, so we
# can't just let this default to `github.ref`.
- uses: actions/checkout@v7
with:
ref: main
submodules: recursive
# dart-lang/setup-dart requests and configures the OIDC token pub.dev's
# trusted-publisher flow needs — this is the piece that was missing
# before; subosito/flutter-action (below) never provisions it.
- uses: dart-lang/setup-dart@v1
# Flutter SDK is required to resolve `flutter: sdk: flutter` in
# pubspec.yaml. Its bundled `dart` binary shadows the one from
# setup-dart on PATH, but both read the same pub credentials that
# setup-dart just wrote.
- uses: subosito/flutter-action@v2
with:
channel: stable
- name: Install dependencies
run: dart pub get
- name: Publish - dry run
run: dart pub publish --dry-run
- name: Publish to pub.dev
run: dart pub publish --force