feat: binary caching

This commit is contained in:
ok-nick 2023-08-03 11:25:22 -04:00
parent 77154a9afb
commit 5a26db60b2
No known key found for this signature in database
GPG key ID: E6F3F722530600D2
2 changed files with 20 additions and 7 deletions

View file

@ -9,7 +9,7 @@
GitHub action to install and run [aftman](https://github.com/LPGhatguy/aftman); a toolchain manager. GitHub action to install and run [aftman](https://github.com/LPGhatguy/aftman); a toolchain manager.
## Usage ## Usage
This is the most common case and automatically provides all the parameters using the latest released version of `aftman`. Use the latest released version of `aftman` with default parameters:
```yaml ```yaml
steps: steps:
- uses: ok-nick/setup-aftman@v0.3.0 - uses: ok-nick/setup-aftman@v0.3.0
@ -23,7 +23,8 @@ steps:
- uses: ok-nick/setup-aftman@v0.3.0 - uses: ok-nick/setup-aftman@v0.3.0
with: with:
version: v1.0.0 # name of git tag in aftman (uses latest by default) version: v1.0.0 # name of git tag in aftman (uses latest by default)
path: some_directory/my_project # path to project directory containing `aftman.toml` path: some_dir/my_project # path to project directory containing `aftman.toml` (uses current directory by default)
cache: true # whether or not to enable binary caching between runs (true by default)
token: ${{ github.token }} # GitHub token to bypass rate limit (passed by default) token: ${{ github.token }} # GitHub token to bypass rate limit (passed by default)
``` ```

View file

@ -4,12 +4,16 @@ author: ok-nick
inputs: inputs:
version: version:
description: "`aftman` Git tag (usually in the form vx.x.x)" description: "`aftman` git tag (usually in the form vx.x.x)"
required: false required: false
path: path:
description: "Path to the `aftman.toml` directory" description: "Path to the `aftman.toml` directory"
default: "." default: "."
required: false required: false
cache:
description: "Whether or not to enable caching"
default: "true"
required: false
token: token:
description: "Github token via `github.token`" description: "Github token via `github.token`"
default: "${{ github.token }}" default: "${{ github.token }}"
@ -27,9 +31,9 @@ runs:
esac esac
gh release download ${{ inputs.version }} --repo LPGhatguy/aftman --pattern $pattern gh release download ${{ inputs.version }} --repo LPGhatguy/aftman --pattern $pattern
shell: bash
env: env:
GITHUB_TOKEN: ${{ inputs.token }} GITHUB_TOKEN: ${{ inputs.token }}
shell: bash
- name: Install aftman - name: Install aftman
run: | run: |
@ -49,21 +53,29 @@ runs:
- name: Set environment variable - name: Set environment variable
if: runner.os == 'Windows' if: runner.os == 'Windows'
run: echo "$HOME/.aftman/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append run: echo "~/.aftman/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: powershell shell: powershell
- name: Set environment variable - name: Set environment variable
if: runner.os != 'Windows' if: runner.os != 'Windows'
run: echo "$HOME/.aftman/bin" >> $GITHUB_PATH run: echo "~/.aftman/bin" >> $GITHUB_PATH
shell: bash shell: bash
- name: Create auth file - name: Create auth file
run: | run: |
cat > $HOME/.aftman/auth.toml << EOF cat > ~/.aftman/auth.toml << EOF
github = "${{ inputs.token }}" github = "${{ inputs.token }}"
EOF EOF
shell: bash shell: bash
- name: Cache binaries
if: ${{ inputs.cache == 'true' }}
uses: actions/cache@v3
with:
path: ~/.aftman/bin
key: ${{ runner.os }}-aftman
shell: bash
- name: Install tools - name: Install tools
run: | run: |
cd ${{ inputs.path }} cd ${{ inputs.path }}