Skip to content

Commit

Permalink
tweak: use cache-busting URLs for downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
passcod committed Apr 3, 2024
1 parent b6563dd commit 91e3fe0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ The above URLs are for the current release. If you want to always get the latest

| Platform | Variant | Download |
| -------- | ------- | -------- |
| Windows | x86 | [bestool.exe](https://tools.ops.tamanu.io/bestool/latest/x86_64-pc-windows-msvc/bestool.exe) |
| Linux | x86 | [bestool](https://tools.ops.tamanu.io/bestool/latest/x86_64-unknown-linux-gnu/bestool) |
| Linux | x86 static | [bestool](https://tools.ops.tamanu.io/bestool/latest/x86_64-unknown-linux-musl/bestool) |
| Linux | ARM64 | [bestool](https://tools.ops.tamanu.io/bestool/latest/aarch64-unknown-linux-musl/bestool) |
| Mac | Intel | [bestool](https://tools.ops.tamanu.io/bestool/latest/x86_64-apple-darwin/bestool) |
| Mac | ARM64 | [bestool](https://tools.ops.tamanu.io/bestool/latest/aarch64-apple-darwin/bestool) |
| Windows | x86 | [bestool.exe](https://tools.ops.tamanu.io/bestool/latest/x86_64-pc-windows-msvc/bestool.exe?latest) |
| Linux | x86 | [bestool](https://tools.ops.tamanu.io/bestool/latest/x86_64-unknown-linux-gnu/bestool?latest) |
| Linux | x86 static | [bestool](https://tools.ops.tamanu.io/bestool/latest/x86_64-unknown-linux-musl/bestool?latest) |
| Linux | ARM64 | [bestool](https://tools.ops.tamanu.io/bestool/latest/aarch64-unknown-linux-musl/bestool?latest) |
| Mac | Intel | [bestool](https://tools.ops.tamanu.io/bestool/latest/x86_64-apple-darwin/bestool?latest) |
| Mac | ARM64 | [bestool](https://tools.ops.tamanu.io/bestool/latest/aarch64-apple-darwin/bestool?latest) |

### In GitHub Actions

```yaml
- name: Download bestool
shell: bash
run: |
curl -Lo ${{ runner.os == 'Windows' && 'bestool.exe' || 'bestool' }} https://tools.ops.tamanu.io/bestool/gha/${{ runner.os }}-${{ runner.arch }}
curl -Lo ${{ runner.os == 'Windows' && 'bestool.exe' || 'bestool' }} https://tools.ops.tamanu.io/bestool/gha/${{ runner.os }}-${{ runner.arch }}?bust=${{ github.run_id }}
[[ -f bestool ]] && chmod +x bestool
- name: Use bestool
Expand All @@ -65,7 +65,7 @@ Or combined:
run: |
bestool=bestool
[[ ${{ runner.os }} == "Windows" ]] && bestool=bestool.exe
curl -Lo $bestool https://tools.ops.tamanu.io/bestool/gha/${{ runner.os }}-${{ runner.arch }}
curl -Lo $bestool https://tools.ops.tamanu.io/bestool/gha/${{ runner.os }}-${{ runner.arch }}?bust=${{ github.run_id }}
[[ -f bestool ]] && chmod +x bestool
./$bestool --version # or something more useful
```
Expand Down
3 changes: 2 additions & 1 deletion src/actions/caddy/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ pub async fn run(ctx: Context<CaddyArgs, DownloadArgs>) -> Result<()> {
let mut url = None;
for target in detected_targets {
let try_url = Url::parse(&format!(
"https://tools.ops.tamanu.io/caddy/{version}/caddy-{target}{ext}",
"https://tools.ops.tamanu.io/caddy/{version}/caddy-{target}{ext}?bust={date}",
ext = if target.contains("windows") {
".exe"
} else {
""
},
date = chrono::Utc::now(),
))
.into_diagnostic()?;
debug!(url=%try_url, "trying URL");
Expand Down
3 changes: 2 additions & 1 deletion src/actions/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ pub async fn run(ctx: Context<SelfUpdateArgs>) -> Result<()> {
let dest = dir.join(&filename);

let url = format!(
"https://tools.ops.tamanu.io/bestool/{version}/{target}/{filename}",
"https://tools.ops.tamanu.io/bestool/{version}/{target}/{filename}?bust={date}",
target = detected_targets
.first()
.cloned()
.unwrap_or_else(|| TARGET.into()),
date = chrono::Utc::now(),
);
info!(url = %url, "downloading");

Expand Down
3 changes: 2 additions & 1 deletion src/actions/walg/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ pub async fn run(ctx: Context<WalgArgs, DownloadArgs>) -> Result<()> {
let mut url = None;
for target in detected_targets {
let try_url = Url::parse(&format!(
"https://tools.ops.tamanu.io/wal-g/{version}/wal-g-{target}{ext}",
"https://tools.ops.tamanu.io/wal-g/{version}/wal-g-{target}{ext}?bust={date}",
ext = if target.contains("windows") {
".exe"
} else {
""
},
date = chrono::Utc::now(),
))
.into_diagnostic()?;
debug!(url=%try_url, "trying URL");
Expand Down

0 comments on commit 91e3fe0

Please sign in to comment.