Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix publish CI #61

Merged
merged 4 commits into from
Nov 5, 2023
Merged
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
41 changes: 21 additions & 20 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Publish
on:
push:
tags:
- 'envied-v[0-9]+.[0-9]+.[0-9]+*'
- 'envied_generator-v[0-9]+.[0-9]+.[0-9]+*'
- 'v[0-9]+.[0-9]+.[0-9]+*'
defaults:
run:
shell: bash
Expand All @@ -23,6 +22,7 @@ jobs:
name: "Publish"
permissions:
id-token: write
contents: write
runs-on: ubuntu-latest
environment: pub.dev
strategy:
Expand All @@ -31,33 +31,28 @@ jobs:
fail-fast: true
max-parallel: 1
steps:
- id: should_publish
name: Check if should publish
run: |
set -e
if [[ $GITHUB_REF =~ ^refs/tags/${{ matrix.package }} ]]; then
echo "SHOULD_RUN=1" >> $GITHUB_ENV
else
echo "SHOULD_RUN=0" >> $GITHUB_ENV
fi
- id: setup_dart
name: Setup Dart SDK
if: ${{ env.SHOULD_RUN == 1 }}
uses: dart-lang/setup-dart@v1
with:
sdk: stable
- id: checkout
name: Checkout repository
if: ${{ env.SHOULD_RUN == 1 }}
uses: actions/checkout@v3
- id: read_version_from_pubspec
name: Read version from pubspec
if: ${{ env.SHOULD_RUN == 1 }}
working-directory: packages/${{ matrix.package }}
run: |
set -e
VERSION=$(yq -r '.version' pubspec.yaml)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Compare version with ref/tag
id: compare_version_with_tag
run: |
set -e
TAG=${GITHUB_REF_NAME#v}
if [[ "$VERSION" != "$TAG" ]]; then
echo "Version in ${{ matrix.package }}/pubspec.yaml ($VERSION) does not match tag ($TAG)"
echo "Skipping publish for ${{ matrix.package }}"
echo "SHOULD_RUN=0" >> $GITHUB_ENV
else
echo "SHOULD_RUN=1" >> $GITHUB_ENV
fi
- id: check_changelog
name: Check CHANGELOG.md
if: ${{ env.SHOULD_RUN == 1 }}
Expand Down Expand Up @@ -89,8 +84,14 @@ jobs:
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 -en "\n[https://pub.dev/packages/${{ matrix.package }}/versions/$VERSION](https://pub.dev/packages/${{ matrix.package }}/versions/$VERSION)" >> $CHANGELOG_PATH
echo "CHANGELOG_PATH=$CHANGELOG_PATH" >> $GITHUB_ENV
- id: setup_dart
name: Setup Dart SDK
if: ${{ env.SHOULD_RUN == 1 }}
uses: dart-lang/setup-dart@v1
with:
sdk: stable
- id: melos
name: Activate melos
if: ${{ env.SHOULD_RUN == 1 }}
Expand Down