Skip to content

Commit

Permalink
Install cw from deb package
Browse files Browse the repository at this point in the history
  • Loading branch information
iainelder committed Jul 13, 2023
1 parent bcf3b19 commit 2a38d13
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/cw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: cw
on:
push:
paths:
- programs/cw/install.bash
- .github/workflows/cw.yml
schedule:
# Not at the start of an hour or a day to decreate the chance of delay.
# See schedule documentation.
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: "17 5 * * *"

workflow_dispatch:

jobs:
test_idempotent_installation:

strategy:
matrix:
os:
- "ubuntu:20.04"
- "ubuntu:22.04"

runs-on: ubuntu-latest
container:
image: "${{ matrix.os }}"

steps:

- name: Check out code
uses: actions/checkout@v3

- name: Prepare Docker
run: ./scripts/prepare_docker.bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install cw
shell: su norm --command "bash --login {0}"
run: programs/cw/install.bash

- name: Install cw again (test idempotency)
shell: su norm --command "bash --login {0}"
run: programs/cw/install.bash

33 changes: 33 additions & 0 deletions programs/cw/install.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Name: cw
# Source: https://github.com/lucagrulla/cw/

set -euxo pipefail

cd "$(mktemp --dir)"

sudo apt-get update

sudo apt-get --assume-yes install \
curl \
jq

browser_download_url=$(
curl -Ss 'https://api.github.com/repos/lucagrulla/cw/releases/latest' |
jq -r '.assets[] | select(.name == "cw_amd64.deb") | .browser_download_url'
)

package_filename=$(
curl \
--silent \
--show-error \
--url "$browser_download_url" \
--location \
--remote-name \
--write-out '%{filename_effective}'
)

sudo apt-get install "./${package_filename}"

cw --version

0 comments on commit 2a38d13

Please sign in to comment.