From 68a53e48b8fec582c54eb669b04305cd14ca8369 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 30 Nov 2023 14:14:21 +0100 Subject: [PATCH 1/9] Add workflow to automatically update pixi version --- .github/workflows/build.yml | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6478dbc..2008322 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,8 @@ on: pull_request: branches: [main] merge_group: + schedule: + - cron: 0 6 * * MON jobs: build: @@ -29,7 +31,7 @@ jobs: - name: Rebuild the dist/ directory run: pnpm build - + - name: Lint run: pnpm lint @@ -45,6 +47,31 @@ jobs: count_expected=10 count_actual="$(grep -c "setup-pixi@v$latest_version" README.md || true)" if [ "$count_actual" -ne "$count_expected" ]; then - echo "::error file=README.md::Expected $count_expected mentions of setup-pixi@v$latest_version in README.md, but found $count_actual." + echo "::error file=README.md::Expected $count_expected mentions of `setup-pixi@v$latest_version` in README.md, but found $count_actual." + exit 1 + fi + + reference-latest-pixi-version-in-readme: + name: Reference latest Pixi version in README + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Assert latest pixi version is mentioned in README + run: | + latest_version="$(gh repo view --json latestRelease prefix-dev/pixi | jq -r '.latestRelease.tagName')" + count_expected=1 + count_actual="$(grep -c "pixi-version: $latest_version" README.md || true)" + if [ "$count_actual" -ne "$count_expected" ]; then + echo "::error file=README.md::Expected $count_expected mentions of `pixi-version: $latest_version` in README.md, but found $count_actual." + sed -i "s/pixi-version: .*/pixi-version: $latest_version/" README.md exit 1 fi + + - name: Create pull request + uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 + if: always() && github.ref == 'refs/heads/main' + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Reference latest Pixi version in README + title: Reference latest Pixi version in README From af63f565b1abcaa222d5f451c7d89fa34c7b9298 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 30 Nov 2023 14:28:08 +0100 Subject: [PATCH 2/9] . --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2008322..cfea810 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,6 +59,7 @@ jobs: - name: Assert latest pixi version is mentioned in README run: | + set -x latest_version="$(gh repo view --json latestRelease prefix-dev/pixi | jq -r '.latestRelease.tagName')" count_expected=1 count_actual="$(grep -c "pixi-version: $latest_version" README.md || true)" @@ -70,8 +71,9 @@ jobs: - name: Create pull request uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 - if: always() && github.ref == 'refs/heads/main' + if: failure() && github.ref == 'refs/heads/main' with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Reference latest Pixi version in README title: Reference latest Pixi version in README + labels: documentation From 8d66fa490a08d0bcee7ef527924c4c0666d2dc42 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 30 Nov 2023 14:31:29 +0100 Subject: [PATCH 3/9] . --- .github/workflows/build.yml | 42 +++++++++++++++++++++++++++- .github/workflows/check-dist.yml | 48 -------------------------------- 2 files changed, 41 insertions(+), 49 deletions(-) delete mode 100644 .github/workflows/check-dist.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cfea810..8c96c11 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,7 +59,7 @@ jobs: - name: Assert latest pixi version is mentioned in README run: | - set -x + set -euxo pipefail latest_version="$(gh repo view --json latestRelease prefix-dev/pixi | jq -r '.latestRelease.tagName')" count_expected=1 count_actual="$(grep -c "pixi-version: $latest_version" README.md || true)" @@ -68,6 +68,8 @@ jobs: sed -i "s/pixi-version: .*/pixi-version: $latest_version/" README.md exit 1 fi + # env: + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create pull request uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 @@ -77,3 +79,41 @@ jobs: commit-message: Reference latest Pixi version in README title: Reference latest Pixi version in README labels: documentation + + check-dist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Rebuild the dist/ directory + run: pnpm build + + - name: Compare the expected and actual dist/ directories + run: | + if [ "$(git diff --ignore-space-at-eol dist/* | wc -l)" -gt "0" ]; then + echo "Detected uncommitted changes after build. See status below:" + git diff + exit 1 + fi + id: diff + + # If index.js or post.js are different than expected, upload the expected version as an artifact + - uses: actions/upload-artifact@v3 + if: ${{ failure() && steps.diff.conclusion == 'failure' }} + with: + name: dist + path: dist/ diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml deleted file mode 100644 index 50c9853..0000000 --- a/.github/workflows/check-dist.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Check dist - -on: - push: - branches: [main] - pull_request: - branches: [main] - merge_group: - -jobs: - check-dist: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install pnpm - uses: pnpm/action-setup@v2 - with: - version: 8 - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: pnpm - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Rebuild the dist/ directory - run: pnpm build - - - name: Compare the expected and actual dist/ directories - run: | - if [ "$(git diff --ignore-space-at-eol dist/* | wc -l)" -gt "0" ]; then - echo "Detected uncommitted changes after build. See status below:" - git diff - exit 1 - fi - id: diff - - # If index.js or post.js are different than expected, upload the expected version as an artifact - - uses: actions/upload-artifact@v3 - if: ${{ failure() && steps.diff.conclusion == 'failure' }} - with: - name: dist - path: dist/ From 8a10cff163d39350f9c754f7bff48386fd3bc090 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 30 Nov 2023 14:33:32 +0100 Subject: [PATCH 4/9] . --- .github/workflows/build.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c96c11..0600e06 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,8 @@ jobs: - uses: actions/checkout@v4 - name: Assert latest setup-pixi version is mentioned in README - run: | + run: + set -euo pipefail latest_version="$(jq -r '.version' package.json)" count_expected=10 count_actual="$(grep -c "setup-pixi@v$latest_version" README.md || true)" @@ -59,7 +60,7 @@ jobs: - name: Assert latest pixi version is mentioned in README run: | - set -euxo pipefail + set -euo pipefail latest_version="$(gh repo view --json latestRelease prefix-dev/pixi | jq -r '.latestRelease.tagName')" count_expected=1 count_actual="$(grep -c "pixi-version: $latest_version" README.md || true)" @@ -68,8 +69,8 @@ jobs: sed -i "s/pixi-version: .*/pixi-version: $latest_version/" README.md exit 1 fi - # env: - # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create pull request uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 From efcf1fcc544cfdfab55ac74c7eeaa62ea248ec25 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 30 Nov 2023 14:34:39 +0100 Subject: [PATCH 5/9] . --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0600e06..ec9d14a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,13 +42,13 @@ jobs: - uses: actions/checkout@v4 - name: Assert latest setup-pixi version is mentioned in README - run: + run: | set -euo pipefail latest_version="$(jq -r '.version' package.json)" count_expected=10 count_actual="$(grep -c "setup-pixi@v$latest_version" README.md || true)" if [ "$count_actual" -ne "$count_expected" ]; then - echo "::error file=README.md::Expected $count_expected mentions of `setup-pixi@v$latest_version` in README.md, but found $count_actual." + echo "::error file=README.md::Expected $count_expected mentions of \`setup-pixi@v$latest_version\` in README.md, but found $count_actual." exit 1 fi @@ -65,7 +65,7 @@ jobs: count_expected=1 count_actual="$(grep -c "pixi-version: $latest_version" README.md || true)" if [ "$count_actual" -ne "$count_expected" ]; then - echo "::error file=README.md::Expected $count_expected mentions of `pixi-version: $latest_version` in README.md, but found $count_actual." + echo "::error file=README.md::Expected $count_expected mentions of \`pixi-version: $latest_version\` in README.md, but found $count_actual." sed -i "s/pixi-version: .*/pixi-version: $latest_version/" README.md exit 1 fi From 7ddd42b4f7ca0c5dc059a0255601695e4ffac2af Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 30 Nov 2023 14:38:17 +0100 Subject: [PATCH 6/9] . --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec9d14a..a155da4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,6 +55,9 @@ jobs: reference-latest-pixi-version-in-readme: name: Reference latest Pixi version in README runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write steps: - uses: actions/checkout@v4 @@ -74,7 +77,7 @@ jobs: - name: Create pull request uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 - if: failure() && github.ref == 'refs/heads/main' + if: failure() with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Reference latest Pixi version in README From 8079a4969d73f4f394f2bd7705502e966e335724 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 30 Nov 2023 14:39:43 +0100 Subject: [PATCH 7/9] . --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a155da4..1ab8ade 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,6 +83,7 @@ jobs: commit-message: Reference latest Pixi version in README title: Reference latest Pixi version in README labels: documentation + base: main check-dist: runs-on: ubuntu-latest From 51daa85a215e359bea9c6275c79b42b12a23abcf Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 30 Nov 2023 14:42:15 +0100 Subject: [PATCH 8/9] . --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1ab8ade..8505fea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,7 +56,7 @@ jobs: name: Reference latest Pixi version in README runs-on: ubuntu-latest permissions: - contents: read + contents: write pull-requests: write steps: - uses: actions/checkout@v4 From 21be5fb687fe78e7ed1e72ba86ad157efed9996b Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 30 Nov 2023 14:43:41 +0100 Subject: [PATCH 9/9] . --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8505fea..120c782 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -77,13 +77,12 @@ jobs: - name: Create pull request uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 - if: failure() + if: failure() && github.ref_name == 'main' with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Reference latest Pixi version in README title: Reference latest Pixi version in README labels: documentation - base: main check-dist: runs-on: ubuntu-latest