Skip to content

Commit 5aa1387

Browse files
authored
Replace node with a simple bash script (#19)
1 parent 6caa78f commit 5aa1387

15 files changed

Lines changed: 54 additions & 7235 deletions

.envrc

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/continuous_delivery.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,11 @@ jobs:
1515
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1616
steps:
1717
- uses: actions/checkout@v3
18-
- uses: cachix/install-nix-action@v18
19-
with:
20-
extra_nix_config: |
21-
keep-derivations = true
22-
keep-outputs = true
2318
- run: |
2419
git config user.name "$GITHUB_ACTOR"
2520
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
2621
27-
version=$(npm -j list setup-captain | jq -r .version)
22+
version=$(cat version)
2823
majorMinor=$(echo $version | awk -F '.' '{print $1 "." $2}')
2924
3025
git tag "v$version"

.github/workflows/continuous_integration.yaml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,6 @@ name: Continuous Integration
22
on:
33
push:
44
jobs:
5-
type-check:
6-
name: Type check
7-
runs-on: ubuntu-latest
8-
steps:
9-
- uses: actions/checkout@v3
10-
- uses: cachix/install-nix-action@v18
11-
with:
12-
extra_nix_config: |
13-
keep-derivations = true
14-
keep-outputs = true
15-
- run: |
16-
mv dist/index.js dist/index.old.$GITHUB_RUN_ID.$GITHUB_RUN_NUMBER.js
17-
nix develop --command npm install
18-
nix develop --command npm run build
19-
diff dist/index.old.$GITHUB_RUN_ID.$GITHUB_RUN_NUMBER.js dist/index.js
20-
215
test_default_version:
226
runs-on: ubuntu-latest
237
steps:
@@ -51,17 +35,3 @@ jobs:
5135
with:
5236
version: unstable
5337
- run: captain --version | grep '^unstable-'
54-
55-
lint:
56-
name: Lint
57-
runs-on: ubuntu-latest
58-
steps:
59-
- uses: actions/checkout@v3
60-
- uses: cachix/install-nix-action@v18
61-
with:
62-
extra_nix_config: |
63-
keep-derivations = true
64-
keep-outputs = true
65-
- run: nix develop --command npm install
66-
- run: nix develop --command npx prettier --check "src/**/*.ts"
67-
- run: nix fmt -- --check flake.nix

.github/workflows/merge_requirements.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,11 @@ jobs:
88
if: ${{ github.base_ref == 'v1' }}
99
steps:
1010
- uses: actions/checkout@v3
11-
- uses: cachix/install-nix-action@v18
12-
with:
13-
extra_nix_config: |
14-
keep-derivations = true
15-
keep-outputs = true
16-
- run: nix-store --import < /tmp/nix-cache
17-
if: "steps.nix-cache.outputs.cache-hit == 'true'"
1811
- run: |
19-
newVersion=$(npm -j list setup-captain | jq -r .version)
12+
newVersion=$(cat version)
2013
majorVersion=$(echo $newVersion | awk -F '.' '{print $1}')
2114
git fetch && git checkout origin/v1
22-
oldVersion=$(npm -j list setup-captain | jq -r .version)
15+
oldVersion=$(cat version || echo "1.3.0")
2316
latestVersion=$(echo "$newVersion $oldVersion" | sed 's/\ /\n/' | sort -rV | head -n 1)
2417
2518
if [[ "$majorVersion" != "1" ]]; then

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
/.direnv
2-
/node_modules

.prettierrc.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

action.yaml

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,53 @@ inputs:
1313
default: v2
1414
required: false
1515
runs:
16-
using: 'node20'
17-
main: 'dist/index.js'
16+
using: composite
17+
steps:
18+
- name: Install Captain CLI
19+
shell: bash
20+
env:
21+
VERSION: ${{ inputs.version }}
22+
run: |
23+
version="$VERSION"
24+
25+
# Normalize version aliases
26+
if [[ "$version" == "latest" ]]; then
27+
version="v2"
28+
fi
29+
30+
# Add v prefix if version starts with a number
31+
if [[ "$version" =~ ^[0-9]+ ]]; then
32+
version="v$version"
33+
fi
34+
35+
# Detect OS
36+
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
37+
extension=""
38+
if [[ "$os" == "mingw"* || "$os" == "msys"* || "$os" == "cygwin"* ]]; then
39+
os="windows"
40+
extension=".exe"
41+
fi
42+
43+
# Detect architecture
44+
arch="$(uname -m)"
45+
if [[ "$arch" == "x86_64" ]]; then
46+
arch="x86_64"
47+
elif [[ "$arch" == "arm64" || "$arch" == "aarch64" ]]; then
48+
arch="aarch64"
49+
fi
50+
51+
url="https://releases.captain.build/${version}/${os}/${arch}/captain${extension}"
52+
53+
echo "Fetching $url"
54+
curl -fsSL "$url" -o /tmp/captain${extension}
55+
56+
echo "Installing to /usr/local/bin/captain"
57+
install /tmp/captain${extension} /usr/local/bin/captain
58+
59+
cli_version="$(captain --version)"
60+
alias_versions="v1 v2 unstable"
61+
if [[ "$cli_version" != "$version" && ! " $alias_versions " =~ " $version " ]]; then
62+
echo "::error::Unexpected version of Captain installed. Expected $version but installed $cli_version"
63+
exit 1
64+
fi
65+
echo "captain $cli_version is installed"

0 commit comments

Comments
 (0)