From 544bb0a294108b8df6a21aea18db977da1e09d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemen=20Tu=C5=A1ar?= Date: Sat, 5 Aug 2023 11:28:22 +0200 Subject: [PATCH 1/2] :construction_worker: use yq to manipulate pubspec.yaml in publish CI --- .github/workflows/publish.yml | 13 ++++++++++--- .github/workflows/publish_dry_run.yml | 14 ++++++++++++-- tool/publish.sh | 19 ------------------- 3 files changed, 22 insertions(+), 24 deletions(-) delete mode 100644 tool/publish.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 41280a53..5dadc224 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -74,11 +74,17 @@ jobs: run: | set -e mkdir -p $XDG_CONFIG_HOME/dart - echo '${{ secrets.CREDENTIAL_JSON }}' > "$XDG_CONFIG_HOME/dart/pub-credentials.json" + echo -n '${{ secrets.CREDENTIAL_JSON }}' > $XDG_CONFIG_HOME/dart/pub-credentials.json - name: Publish id: publish if: ${{ env.IS_VERSION_GREATER == 1 }} - run: bash tool/publish.sh ${{ matrix.package }} + run: | + set -e + pushd ${{ matrix.package }} || exit + yq 'del(.dependency_overrides)' pubspec.yaml | yq 'del(.. | select(has("path")).path)' - | sed 's/{\(.*\)}/\1/g' > $RUNNER_TEMP/pubspec.yaml + mv $RUNNER_TEMP/pubspec.yaml pubspec.yaml + dart pub publish --force + popd || exit - name: Skip publish id: skip_publish if: ${{ env.IS_VERSION_GREATER == 0 }} @@ -87,4 +93,5 @@ jobs: id: cleanup if: ${{ always() }} run: | - rm -rf "$XDG_CONFIG_HOME/dart/pub-credentials.json" \ No newline at end of file + rm -rf $XDG_CONFIG_HOME/dart/pub-credentials.json + rm -rf $RUNNER_TEMP/pubspec.yaml \ No newline at end of file diff --git a/.github/workflows/publish_dry_run.yml b/.github/workflows/publish_dry_run.yml index 14d51179..7d4ba15e 100644 --- a/.github/workflows/publish_dry_run.yml +++ b/.github/workflows/publish_dry_run.yml @@ -70,8 +70,18 @@ jobs: - name: Publish (dry run) id: publish_dry_run if: ${{ env.IS_VERSION_GREATER == 1 }} - run: bash tool/publish.sh ${{ matrix.package }} --dry-run + run: | + set -e + pushd ${{ matrix.package }} || exit + yq 'del(.dependency_overrides)' pubspec.yaml | yq 'del(.. | select(has("path")).path)' - | sed 's/{\(.*\)}/\1/g' > $RUNNER_TEMP/pubspec.yaml + mv $RUNNER_TEMP/pubspec.yaml pubspec.yaml + dart pub publish --dry-run + popd || exit - name: Skip publish (dry run) id: skip_publish_dry_run if: ${{ env.IS_VERSION_GREATER == 0 }} - run: echo "Skipping publish (dry run) for ${{ matrix.package }} because the version is not greater than the one on pub.dev" \ No newline at end of file + run: echo "Skipping publish (dry run) for ${{ matrix.package }} because the version is not greater than the one on pub.dev" + - name: Cleanup + if: ${{ always() }} + run: | + rm -rf $RUNNER_TEMP/pubspec.yaml \ No newline at end of file diff --git a/tool/publish.sh b/tool/publish.sh deleted file mode 100644 index f5b81db2..00000000 --- a/tool/publish.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -set -e - -PKG=$1 -echo -e "\033[1mPKG: ${PKG}\033[22m" -pushd "${PKG}" - -sed '/Comment before publish$/,+2 d' pubspec.yaml > pubspec.temp.yaml -rm pubspec.yaml -mv pubspec.temp.yaml pubspec.yaml - -if [ "$2" == "--dry-run" ]; then - dart pub publish --dry-run -else - dart pub publish --force -fi - -popd \ No newline at end of file From 4e666ddf45824ef09cb10d643a55b17fcd153cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemen=20Tu=C5=A1ar?= Date: Sat, 5 Aug 2023 15:53:20 +0200 Subject: [PATCH 2/2] :construction_worker: use yq to manipulate pubspec.yaml in publish CI --- .github/workflows/publish.yml | 4 +--- .github/workflows/publish_dry_run.yml | 7 +------ chopper/pubspec.yaml | 3 +++ chopper_built_value/pubspec.yaml | 1 - chopper_generator/pubspec.yaml | 1 - 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5dadc224..a9da77ad 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -81,8 +81,7 @@ jobs: run: | set -e pushd ${{ matrix.package }} || exit - yq 'del(.dependency_overrides)' pubspec.yaml | yq 'del(.. | select(has("path")).path)' - | sed 's/{\(.*\)}/\1/g' > $RUNNER_TEMP/pubspec.yaml - mv $RUNNER_TEMP/pubspec.yaml pubspec.yaml + yq -i 'del(.dependency_overrides)' pubspec.yaml dart pub publish --force popd || exit - name: Skip publish @@ -94,4 +93,3 @@ jobs: if: ${{ always() }} run: | rm -rf $XDG_CONFIG_HOME/dart/pub-credentials.json - rm -rf $RUNNER_TEMP/pubspec.yaml \ No newline at end of file diff --git a/.github/workflows/publish_dry_run.yml b/.github/workflows/publish_dry_run.yml index 7d4ba15e..6ab66c84 100644 --- a/.github/workflows/publish_dry_run.yml +++ b/.github/workflows/publish_dry_run.yml @@ -73,15 +73,10 @@ jobs: run: | set -e pushd ${{ matrix.package }} || exit - yq 'del(.dependency_overrides)' pubspec.yaml | yq 'del(.. | select(has("path")).path)' - | sed 's/{\(.*\)}/\1/g' > $RUNNER_TEMP/pubspec.yaml - mv $RUNNER_TEMP/pubspec.yaml pubspec.yaml + yq -i 'del(.dependency_overrides)' pubspec.yaml dart pub publish --dry-run popd || exit - name: Skip publish (dry run) id: skip_publish_dry_run if: ${{ env.IS_VERSION_GREATER == 0 }} run: echo "Skipping publish (dry run) for ${{ matrix.package }} because the version is not greater than the one on pub.dev" - - name: Cleanup - if: ${{ always() }} - run: | - rm -rf $RUNNER_TEMP/pubspec.yaml \ No newline at end of file diff --git a/chopper/pubspec.yaml b/chopper/pubspec.yaml index 0e86235c..5f57ccb0 100644 --- a/chopper/pubspec.yaml +++ b/chopper/pubspec.yaml @@ -25,5 +25,8 @@ dev_dependencies: lints: ^2.1.1 test: ^1.24.4 transparent_image: ^2.0.1 + chopper_generator: ^7.0.0 + +dependency_overrides: chopper_generator: path: ../chopper_generator diff --git a/chopper_built_value/pubspec.yaml b/chopper_built_value/pubspec.yaml index a59baadb..b23d0a66 100644 --- a/chopper_built_value/pubspec.yaml +++ b/chopper_built_value/pubspec.yaml @@ -21,6 +21,5 @@ dev_dependencies: lints: ^2.1.1 dependency_overrides: - # Comment before publish chopper: path: ../chopper diff --git a/chopper_generator/pubspec.yaml b/chopper_generator/pubspec.yaml index ac8b3aa7..4d541b87 100644 --- a/chopper_generator/pubspec.yaml +++ b/chopper_generator/pubspec.yaml @@ -26,6 +26,5 @@ dev_dependencies: test: ^1.24.4 dependency_overrides: - # Comment before publish chopper: path: ../chopper