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

Installer updates #207

Merged
merged 4 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
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
47 changes: 47 additions & 0 deletions .github/workflows/cd.installer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
on:
push:
branches: main
paths: installer.sh

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: 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 }}
10 changes: 0 additions & 10 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ jobs:
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

- uses: git-actions/set-user@v1
- run: |
git add dist
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/ci.installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,15 @@ jobs:
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
18 changes: 12 additions & 6 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ _install_pkgx() {
_should_install_pkgx() {
if [ ! -f /usr/local/bin/pkgx ]; then
return 0
elif /usr/local/bin/pkgx --silent semverator gt \
$(curl -Ssf https://pkgx.sh/VERSION) \
$(/usr/local/bin/pkgx --version | awk '{print $2}') >/dev/null 2>&1
then
return 0
else
# if the installed version is less than the available version then upgrade
/usr/local/bin/pkgx --silent semverator gt \
$(curl -Ssf https://pkgx.sh/VERSION) \
$(/usr/local/bin/pkgx --version | awk '{print $2}') >/dev/null 2>&1
return 1
fi
}

Expand All @@ -109,7 +111,7 @@ _should_install_pkgx() {
if _should_install_pkgx; then
_install_pkgx "$@"
elif [ $# -eq 0 ]; then
echo "pkgx already up-to-date" >&2
echo "$(pkgx --version) already installed" >&2
fi

if _is_ci; then
Expand Down Expand Up @@ -145,7 +147,11 @@ if [ $# -gt 0 ]; then
pkgx "$@"
elif [ $(basename "/$0") != 'installer.sh' ]; then
# ^^ temporary exception for action.ts
eval "$(pkgx --shellcode)" 2>/dev/null

if type eval >/dev/null 2>&1; then
# we `type eval` as on Travis there was no `eval`!
eval "$(pkgx --shellcode)" 2>/dev/null
fi

if ! _is_ci; then
echo "now type: pkgx --help" >&2
Expand Down