From 84725b080c8cb343d36e216f134bf41144a305d1 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 15 Jan 2025 13:08:49 -0500 Subject: [PATCH] The v2 installer is not externally supported --- .github/workflows/cd.installer.yml | 51 --------- .github/workflows/cd.yml | 77 ------------- .github/workflows/ci.installer.yml | 176 ----------------------------- scripts/publish-release.sh | 93 +++++++++++++++ 4 files changed, 93 insertions(+), 304 deletions(-) delete mode 100644 .github/workflows/cd.installer.yml delete mode 100644 .github/workflows/cd.yml delete mode 100644 .github/workflows/ci.installer.yml create mode 100644 scripts/publish-release.sh diff --git a/.github/workflows/cd.installer.yml b/.github/workflows/cd.installer.yml deleted file mode 100644 index 5d3df6dc..00000000 --- a/.github/workflows/cd.installer.yml +++ /dev/null @@ -1,51 +0,0 @@ -on: - push: - branches: main - paths: - - installer.sh - - .github/workflows/cd.installer.yml - -jobs: - qa: - uses: ./.github/workflows/ci.installer.yml - - put: - permissions: - deployments: write - needs: qa - runs-on: ubuntu-latest - steps: - - name: Create Deployment - uses: bobheadxi/deployments@v1 - id: deployment - with: - step: start - env: installer - - - uses: actions/checkout@v4 - - - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-1 - - - run: - aws s3 cp - ./installer.sh s3://www.pkgx.sh/installer.sh - --metadata-directive REPLACE - --cache-control no-cache,must-revalidate - - - run: - aws cloudfront create-invalidation - --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} - --paths / /installer.sh - - - name: Seal Deployment - uses: bobheadxi/deployments@v1 - if: always() - with: - env: installer - step: finish - status: ${{ job.status }} - deployment_id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index 36fbaa4d..00000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,77 +0,0 @@ -on: - workflow_dispatch: - inputs: - version: - required: true - -jobs: - qa-installer: - uses: ./.github/workflows/ci.installer.yml - qa-action: - uses: ./.github/workflows/ci.action.yml - - dist: - needs: [qa-installer, qa-action] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: curl -Ssf https://pkgx.sh/$(uname)/$(uname -m).tgz | sudo tar xz -C /usr/local/bin - - run: ./scripts/dist.sh --minify - - uses: actions/upload-artifact@v3 - with: - name: dist - path: dist - - put: - permissions: - contents: write - deployments: write - needs: dist - runs-on: ubuntu-latest - steps: - - name: Create Deployment - uses: bobheadxi/deployments@v1 - id: deployment - with: - step: start - env: aws - - - uses: actions/checkout@v4 - - uses: actions/download-artifact@v3 - with: - name: dist - path: dist - - - uses: git-actions/set-user@v1 - - - run: | - if ! git diff --exit-code; then - git add dist - git commit -m v${{ github.event.inputs.version }} - git tag v${{ github.event.inputs.version }} - git push origin v${{ github.event.inputs.version }} main - fi - - - uses: softprops/action-gh-release@v1 - with: - files: ./installer.sh - tag_name: v${{ github.event.inputs.version }} - fail_on_unmatched_files: true - - - uses: fischerscode/tagger@v0 - with: - prefix: v - tag: v${{ github.event.inputs.version }} - - - run: | - git tag --force latest - git push origin latest - - - name: Seal Deployment - uses: bobheadxi/deployments@v1 - if: always() - with: - env: aws - step: finish - status: ${{ job.status }} - deployment_id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/.github/workflows/ci.installer.yml b/.github/workflows/ci.installer.yml deleted file mode 100644 index 5bc34173..00000000 --- a/.github/workflows/ci.installer.yml +++ /dev/null @@ -1,176 +0,0 @@ -on: - workflow_call: - pull_request: - paths: - - installer.sh - - .github/workflows/ci.installer.yml - -concurrency: - group: ${{ github.ref || 'ci' }}/installer.sh - cancel-in-progress: true - -permissions: - contents: read - -jobs: - install-pkgx: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - macos-latest - - ubuntu-latest - steps: - - uses: actions/checkout@v4 - # using cat | sh to emulate the curl command we tell people to use - - run: cat ./installer.sh | sh - - run: pkgx --version - - usage-as-proxy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: cat ./installer.sh | sh -s node --eval 'console.log(1)' - - run: ./installer.sh sh -c "which pkgx" - - run: source <(cat ./installer.sh) duf - - run: if command -v pkgx; then exit 1; fi - - sudo-not-required: - runs-on: ubuntu-latest - container: debian:buster-slim - steps: - - uses: actions/checkout@v4 - - uses: actions/checkout@v4 - with: - ref: curl - path: bin - - run: ./installer.sh - env: - PATH: ${{ github.workspace }}/bin:/usr/bin:/bin - - eval-bash: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: | - eval "$(cat ./installer.sh)" - env +duf - duf --version - - test -n "$BASH_VERSION" - test -z "$ZSH_VERSION" - shell: bash -e {0} - - # check pkgx was installed despite executing via `eval` - - run: - pkgx duf --version - - eval-zsh: - runs-on: ubuntu-latest - steps: - - name: prep - run: sudo apt-get update && sudo apt-get install -y zsh - - - uses: actions/checkout@v4 - - run: | - eval "$(cat ./installer.sh)" - env +duf - duf --version - - test -n "$ZSH_VERSION" - test -z "$BASH_VERSION" - shell: zsh -e {0} - - eval-posix-sh: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: | - eval "$(cat ./installer.sh)" - env +duf - duf --version - - test -z "$ZSH_VERSION" - test -z "$BASH_VERSION" - shell: /bin/sh -e {0} - - sudo-required: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: sudo chmod go-w /usr/local/bin - # ^^ we run as `runner` but this dir has 999 perms - - name: check - run: if touch /usr/local/bin/foo; then exit 1; fi - - run: ./installer.sh - - run: test "$(which pkgx)" = /usr/local/bin/pkgx - - no-dirs: - strategy: - matrix: - dir: [/usr/local, /usr/local/bin] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: sudo mv ${{ matrix.dir }} $(mktemp -d) - - run: ./installer.sh - - run: pkgx duf --version - - multiple-apply-is-ok: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: cat ./installer.sh | sh - - run: cat ./installer.sh | sh - - linuxen: - continue-on-error: true - runs-on: ubuntu-latest - strategy: - matrix: - container: - - debian:buster-slim - - debian:bullseye-slim - - debian:bookworm-slim - - - archlinux:latest - - # - ubuntu:trusty glibc too old - # - ubuntu:xenial glibc too old - # - ubuntu:bionic glibc too old - # - ubuntu:lunar out of support - - ubuntu:focal - - ubuntu:jammy - - ubuntu:24.04 - - ubuntu:24.10 - - - fedora:latest - - # - nixos/nix:latest can’t exec - # - alpine:latest pkgx binary doesn’t actually end up on the system (wtf) - container: ${{ matrix.container }} - steps: - - uses: actions/checkout@v4 - - - uses: actions/checkout@v4 - with: - ref: curl - path: bin - - - run: ./installer.sh - env: - PATH: ${{ github.workspace }}/bin:/usr/bin:/bin - - - run: pkgx node --eval 'console.log(1)' - - upgrades: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: - curl https://dist.pkgx.dev/pkgx.sh/linux/x86-64/v1.0.0.tar.gz | - tar xz --strip-components=3 - - run: mv pkgx /usr/local/bin - - run: test "$(pkgx --version)" = 'pkgx 1.0.0' - - run: ./installer.sh - - run: pkgx semverator gt $(pkgx --version | awk '{print $2}') 1.0.0 diff --git a/scripts/publish-release.sh b/scripts/publish-release.sh new file mode 100644 index 00000000..e5625707 --- /dev/null +++ b/scripts/publish-release.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env -S pkgx +bun +npm +gum bash -eo pipefail + +cd "$(dirname "$0")"/.. + +if ! git diff-index --quiet HEAD --; then + echo "error: dirty working tree" >&2 + exit 1 +fi + +if [ "$(git rev-parse --abbrev-ref HEAD)" != main ]; then + echo "error: requires main branch" >&2 + exit 1 +fi + +if test "$VERBOSE"; then + set -x +fi + +# ensure we have the latest version tags +git fetch origin -pft + +# ensure github tags the right release +git push origin main + +versions="$(git tag | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+')" +v_latest="$(bunx -- semver --include-prerelease $versions | tail -n1)" + +case $1 in +major|minor|patch|prerelease) + v_new=$(bunx -- semver bump $v_latest --increment $1) + ;; +"") + echo "usage $0 " >&2 + exit 1;; +*) + if test "$(bunx -- semver """$1""")" != "$1"; then + echo "$1 doesn't look like valid semver." + exit 1 + fi + v_new=$1 + ;; +esac + +if [ $v_new = $v_latest ]; then + echo v"$v_new already exists!" >&2 + exit 1 +fi + +if ! gh release view v$v_new >/dev/null 2>&1; then + gum confirm "prepare draft release for v$v_new?" || exit 1 + + gh release create \ + v$v_new \ + --draft=true \ + --generate-notes \ + --notes-start-tag=v$v_latest \ + --title=v$v_new +else + gum format "> existing $v_new release found, using that" + echo #spacer +fi + + +gh workflow run ci.action.yml --raw-field version="$v_new" +# ^^ infuriatingly does not tell us the ID of the run + +gum spin --title 'sleeping 5s because GitHub API is slow' -- sleep 5 + +run_id=$(gh run list --json databaseId --workflow=ci.action.yml | jq '.[0].databaseId') + +if ! gh run watch --exit-status $run_id; then + foo=$? + gum format -- "> gh run view --web $run_id" + exit $foo +fi + +./dist.sh +git add ../dist +git commit --message v$v_new +git tag v$v_new +git push origin main v$v_new + +gh release view v$v_new + +gum confirm "draft prepared, release v$v_new?" || exit 1 + +gh release edit \ + v$v_new \ + --verify-tag \ + --draft=false + +git checkout main +git branch -D v$v_new-branch