Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This action provides the following functionality for GitHub Actions users:

See [action.yml](action.yml)

**Basic:**
**Basic** (automatically uses the latest GitHub release):

```yaml
steps:
Expand Down
3 changes: 1 addition & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ author: 'amyu'

inputs:
version:
description: 'Bundletool version'
description: 'Bundletool version. If not specified, downloads the latest GitHub release.'
required: false
default: '1.18.3'

runs:
using: 'node24'
Expand Down
21 changes: 20 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

36 changes: 35 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,43 @@ import fs from 'fs/promises'
import path from 'path'
import os from 'os'

// Fetch the latest release metadata from GitHub
async function getLatestVersion(): Promise<string> {
const response = await fetch(
'https://github.com/google/bundletool/releases/latest',
{redirect: 'manual'}
)

const location = response.headers.get('location')

if (!location) {
throw new Error(
'Unable to determine latest release location from GitHub response'
)
}

const tag = location.split('/').pop()

if (!tag) {
throw new Error(
'Unable to extract version tag from GitHub redirect location'
)
}

return tag
}

// Main action entry point
async function run(): Promise<void> {
try {
const version = core.getInput('version')
let version = core.getInput('version')

if (!version) {
core.info('Fetching latest bundletool release from GitHub…')
version = await getLatestVersion()
core.info(`Using latest version: ${version}`)
}

const downloadVersion = `${version}/bundletool-all-${version}.jar`

const downloadDir = path.join(os.homedir(), '.bundletool')
Expand Down
Loading