Skip to content

Commit

Permalink
chore: fix publish CI (#61)
Browse files Browse the repository at this point in the history
* chore: fix publish CI

* chore: fix publish CI

* chore: fix publish CI

* chore: fix publish CI
  • Loading branch information
techouse authored Nov 5, 2023
1 parent 0d08946 commit b761441
Showing 1 changed file with 21 additions and 20 deletions.
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

0 comments on commit b761441

Please sign in to comment.