Skip to content

Commit 54e1652

Browse files
authored
Merge pull request #207 from pkgxdev/installer-updates
Installer updates
2 parents de4de59 + 07243f5 commit 54e1652

4 files changed

Lines changed: 71 additions & 16 deletions

File tree

.github/workflows/cd.installer.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
on:
2+
push:
3+
branches: main
4+
paths: installer.sh
5+
6+
jobs:
7+
qa:
8+
uses: ./.github/workflows/ci.installer.yml
9+
10+
put:
11+
permissions:
12+
deployments: write
13+
needs: qa
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Create Deployment
17+
uses: bobheadxi/deployments@v1
18+
id: deployment
19+
with:
20+
step: start
21+
env: installer
22+
23+
- uses: aws-actions/configure-aws-credentials@v4
24+
with:
25+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
26+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
27+
aws-region: us-east-1
28+
29+
- run:
30+
aws s3 cp
31+
./installer.sh s3://www.pkgx.sh/installer.sh
32+
--metadata-directive REPLACE
33+
--cache-control no-cache,must-revalidate
34+
35+
- run:
36+
aws cloudfront create-invalidation
37+
--distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }}
38+
--paths / /installer.sh
39+
40+
- name: Seal Deployment
41+
uses: bobheadxi/deployments@v1
42+
if: always()
43+
with:
44+
env: installer
45+
step: finish
46+
status: ${{ job.status }}
47+
deployment_id: ${{ steps.deployment.outputs.deployment_id }}

.github/workflows/cd.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ jobs:
4848
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
4949
aws-region: us-east-1
5050

51-
- run:
52-
aws s3 cp
53-
./installer.sh s3://www.pkgx.sh/installer.sh
54-
--metadata-directive REPLACE
55-
--cache-control no-cache,must-revalidate
56-
- run:
57-
aws cloudfront create-invalidation
58-
--distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }}
59-
--paths / /installer.sh
60-
6151
- uses: git-actions/set-user@v1
6252
- run: |
6353
git add dist

.github/workflows/ci.installer.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,15 @@ jobs:
160160
PATH: ${{ github.workspace }}/bin:/usr/bin:/bin
161161

162162
- run: pkgx node --eval 'console.log(1)'
163+
164+
upgrades:
165+
runs-on: ubuntu-latest
166+
steps:
167+
- uses: actions/checkout@v4
168+
- run:
169+
curl https://dist.pkgx.dev/pkgx.sh/linux/x86-64/v1.0.0.tar.gz |
170+
tar xz --strip-components=3
171+
- run: mv pkgx /usr/local/bin
172+
- run: test "$(pkgx --version)" = 'pkgx 1.0.0'
173+
- run: ./installer.sh
174+
- run: pkgx semverator gt $(pkgx --version | awk '{print $2}') 1.0.0

installer.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ _install_pkgx() {
9696
_should_install_pkgx() {
9797
if [ ! -f /usr/local/bin/pkgx ]; then
9898
return 0
99+
elif /usr/local/bin/pkgx --silent semverator gt \
100+
$(curl -Ssf https://pkgx.sh/VERSION) \
101+
$(/usr/local/bin/pkgx --version | awk '{print $2}') >/dev/null 2>&1
102+
then
103+
return 0
99104
else
100-
# if the installed version is less than the available version then upgrade
101-
/usr/local/bin/pkgx --silent semverator gt \
102-
$(curl -Ssf https://pkgx.sh/VERSION) \
103-
$(/usr/local/bin/pkgx --version | awk '{print $2}') >/dev/null 2>&1
105+
return 1
104106
fi
105107
}
106108

@@ -109,7 +111,7 @@ _should_install_pkgx() {
109111
if _should_install_pkgx; then
110112
_install_pkgx "$@"
111113
elif [ $# -eq 0 ]; then
112-
echo "pkgx already up-to-date" >&2
114+
echo "$(pkgx --version) already installed" >&2
113115
fi
114116

115117
if _is_ci; then
@@ -145,7 +147,11 @@ if [ $# -gt 0 ]; then
145147
pkgx "$@"
146148
elif [ $(basename "/$0") != 'installer.sh' ]; then
147149
# ^^ temporary exception for action.ts
148-
eval "$(pkgx --shellcode)" 2>/dev/null
150+
151+
if type eval >/dev/null 2>&1; then
152+
# we `type eval` as on Travis there was no `eval`!
153+
eval "$(pkgx --shellcode)" 2>/dev/null
154+
fi
149155

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

0 commit comments

Comments
 (0)