Skip to content

Commit

Permalink
feat: cache support (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored Oct 24, 2024
1 parent b7e7082 commit 4dd9d7d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./
with:
cache: true
- if: runner.os != 'Windows'
run: |
if [[ $(shorebird --version) =~ "Engine β€’ revision" ]]; then
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ Installs and sets up [Shorebird](https://github.com/shorebirdtech/shorebird) for

βœ… Configures the specified version of Flutter

βœ… Optionally cache the Shorebird installation

## Inputs

- `cache`: Cache the Shorebird installation and artifacts. Default: false

## Usage

```yaml
steps:
- uses: shorebirdtech/setup-shorebird@v1
with:
cache: true # Optionally cache the Shorebird installation
- run: shorebird --version
```
66 changes: 58 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,73 @@ branding:
icon: check-circle
color: yellow

inputs:
cache:
description: "Cache the Shorebird installation and artifacts. Default: false"
required: false
default: "false"

runs:
using: composite
steps:
- name: 🐦 Install Shorebird (macOS / Linux)
if: runner.os != 'Windows'
- name: Determine Install Path (MacOS / Linux)
if: ${{ runner.os != 'Windows' }}
id: install-path
run: |
curl --proto '=https' --tlsv1.2 https://raw.githubusercontent.com/shorebirdtech/install/main/install.sh -sSf | bash -s -- --force
install_path=$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.shorebird" || printf %s "${XDG_CONFIG_HOME}/shorebird")
echo $install_path/bin >> $GITHUB_PATH
echo "added $install_path/bin to GITHUB_PATH"
echo install_path=$install_path >> $GITHUB_ENV
shell: bash

- name: Determine Install Path (Windows)
if: ${{ runner.os == 'Windows' }}
id: install-path-windows
run: |
$install_path = [IO.Path]::Combine($home, ".shorebird")
Write-Output "install_path=$install_path" >> $env:GITHUB_ENV
shell: pwsh

- name: πŸ’Ύ Configure Shorebird Cache
if: ${{ inputs.cache == 'true' }}
id: cache-shorebird
uses: actions/cache@v4
with:
path: ${{ env.install_path }}
key: shorebird-cache-key-${{ runner.os }}-${{ runner.arch }}

- name: 🐦 Install Shorebird (MacOS / Linux)
if: ${{ steps.cache-shorebird.outputs.cache-hit != 'true' && runner.os != 'Windows' }}
run: |
curl --proto '=https' --tlsv1.2 https://raw.githubusercontent.com/shorebirdtech/install/main/install.sh -sSf | bash -s -- --force
shell: bash

- name: 🐦 Install Shorebird (Windows)
if: runner.os == 'Windows'
if: ${{ steps.cache-shorebird.outputs.cache-hit != 'true' && runner.os == 'Windows' }}
run: |
Set-ExecutionPolicy RemoteSigned -scope CurrentUser # Needed to execute remote scripts
iwr -UseBasicParsing 'https://raw.githubusercontent.com/shorebirdtech/install/main/install.ps1'|iex
$installDirectory = [IO.Path]::Combine($home, ".shorebird")
Add-Content $env:GITHUB_PATH "$installDirectory\bin"
shell: pwsh

- name: βž• Add Shorebird to Path (MacOS / Linux)
if: ${{ runner.os != 'Windows' }}
run: |
install_path=${{ env.install_path }}
echo $install_path/bin >> $GITHUB_PATH
echo "added $install_path/bin to GITHUB_PATH"
shell: bash

- name: βž• Add Shorebird to Path (Windows)
if: ${{ runner.os == 'Windows' }}
run: |
Add-Content $env:GITHUB_PATH "${{ env.install_path }}\bin"
Write-Output "added $installDirectory\bin to GITHUB_PATH"
shell: pwsh

- name: πŸ„ Ensure Shorebird is Up-to-Date (MacOS / Linux)
if: ${{ steps.cache-shorebird.outputs.cache-hit == 'true' && runner.os != 'Windows' }}
run: shorebird upgrade
shell: bash

- name: πŸ„ Ensure Shorebird is Up-to-Date (Windows)
if: ${{ steps.cache-shorebird.outputs.cache-hit == 'true' && runner.os == 'Windows' }}
run: shorebird upgrade
shell: pwsh

0 comments on commit 4dd9d7d

Please sign in to comment.