### Install Dependencies and Build/Package Project Source: https://github.com/robinraju/release-downloader/blob/main/CONTRIBUTING.md Commands to install project dependencies and then build the TypeScript code and package it for distribution. Requires Node.js v12.x or higher. ```bash npm install npm run build && npm run pack ``` -------------------------------- ### Workflow Usage Example for Local Action Source: https://github.com/robinraju/release-downloader/blob/main/CONTRIBUTING.md YAML configuration demonstrating how to use the action locally within a GitHub Actions workflow. It specifies the path to the action and provides required input parameters. ```yaml uses: ./ with: repository: 'user/repo' tag: '1.0.0' fileName: 'foo.zip' out-file-path: '.' ``` -------------------------------- ### Complete Workflow Example with Release Asset Downloading Source: https://context7.com/robinraju/release-downloader/llms.txt A full GitHub Actions workflow showcasing the robinraju/release-downloader action for downloading application binaries, configuration files, and assets. It includes dynamic tag selection based on inputs, uses output variables from previous steps, and demonstrates extraction of archived assets. ```yaml name: Deploy Application on: workflow_dispatch: inputs: version: description: 'Release version to deploy' required: false default: 'latest' jobs: download-and-deploy: runs-on: ubuntu-latest steps: - name: Download application binary id: download-app uses: robinraju/release-downloader@v1 with: repository: 'myorg/myapp' latest: ${{ github.event.inputs.version == 'latest' }} tag: ${{ github.event.inputs.version != 'latest' && github.event.inputs.version || '' }} fileName: 'myapp-linux-amd64' out-file-path: 'bin' token: ${{ secrets.GITHUB_TOKEN }} - name: Download configuration files uses: robinraju/release-downloader@v1 with: repository: 'myorg/myapp' tag: ${{ steps.download-app.outputs.tag_name }} fileName: 'config-*.yaml' out-file-path: 'config' token: ${{ secrets.GITHUB_TOKEN }} - name: Download and extract assets uses: robinraju/release-downloader@v1 with: repository: 'myorg/myapp' tag: ${{ steps.download-app.outputs.tag_name }} fileName: 'assets.zip' extract: true out-file-path: 'static' token: ${{ secrets.GITHUB_TOKEN }} - name: Prepare deployment run: | chmod +x bin/myapp-linux-amd64 cp config/*.yaml /etc/myapp/ cp -r static/* /var/www/myapp/ - name: Deploy application run: | echo "Deploying version: ${{ steps.download-app.outputs.tag_name }}" echo "Release: ${{ steps.download-app.outputs.release_name }}" systemctl restart myapp - name: Verify deployment run: | sleep 5 curl -f http://localhost:8080/health || exit 1 - name: Upload deployment logs if: always() uses: actions/upload-artifact@v3 with: name: deployment-logs path: /var/log/myapp/ ``` -------------------------------- ### Download Latest Release Assets Using Pattern Matching in YAML Source: https://context7.com/robinraju/release-downloader/llms.txt Downloads files from the latest release matching a pattern like 'app-*.deb' to a specified output path for integration into installation steps. Depends on the release-downloader action; inputs include repository and fileName; outputs files to 'binaries' directory. Limited to latest release unless tag is specified. ```yaml - name: Download latest application binaries uses: robinraju/release-downloader@v1 with: repository: 'mycompany/myapp' latest: true fileName: 'app-*.deb' out-file-path: 'binaries' - name: Install downloaded packages run: | sudo dpkg -i binaries/app-*.deb ``` -------------------------------- ### Run Project Tests Source: https://github.com/robinraju/release-downloader/blob/main/CONTRIBUTING.md Command to execute the project's test suite. This will run all defined tests and report their status, including a successful download test. ```bash npm test ``` -------------------------------- ### Publish Action using ncc and Git Source: https://github.com/robinraju/release-downloader/blob/main/CONTRIBUTING.md Steps to package production dependencies using ncc, add the 'dist' folder to Git, commit, and push to the 'releases/v1' branch to publish the action. ```bash npm run package git add dist git commit -a -m "prod dependencies" git push origin releases/v1 ``` -------------------------------- ### Configure release-downloader action with YAML for various download scenarios Source: https://github.com/robinraju/release-downloader/blob/main/README.md These YAML snippets demonstrate how to set up the release-downloader action to fetch assets from the latest release, specific tags, tarballs, zipballs, multiple files, wildcard patterns, and prereleases. Adjust the input values to match your repository and desired files. The snippets can be used directly in a GitHub workflow file. ```yaml - uses: robinraju/release-downloader@v1 with: # The source repository path. # Expected format {owner}/{repo} # Default: ${{ github.repository }} repository: '' # A flag to set the download target as latest release # The default value is 'false' latest: true # A flag to download from prerelease. It should be combined with latest flag. # The default value is 'false' preRelease: true # The github tag. e.g: v1.0.1 # Download assets from a specific tag/version tag: '' # The release id to download files from releaseId: '' # The name of the file to download. # Use this field only to specify filenames other than tarball or zipball, if any. # Supports wildcard pattern (eg: '*', '*.deb', '*.zip' etc..) fileName: '' # Download the attached tarball (*.tar.gz) tarBall: true # Download the attached zipball (*.zip) zipBall: true # Relative path under $GITHUB_WORKSPACE to place the downloaded file(s) # It will create the target directory automatically if not present # eg: out-file-path: "my-downloads" => It will create directory $GITHUB_WORKSPACE/my-downloads out-file-path: '' # A flag to set if the downloaded assets are archives and should be extracted # Checks all downloaded files if they end with zip, tar or tar.gz and extracts them, if true. # Prints a warning if enabled but file is not an archive - but does not fail. extract: false # Github access token to download files from private repositories # https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets # eg: token: ${{ secrets.MY_TOKEN }} token: '' # The URL of the Github API, only use this input if you are using Github Enterprise # Default: "https://api.github.com" # Use http(s)://[hostname]/api/v3 to access the API for GitHub Enterprise Server github-api-url: '' ``` ```yaml - uses: robinraju/release-downloader@v1 with: latest: true fileName: 'foo.zip' ``` ```yaml - uses: robinraju/release-downloader@v1 with: repository: 'owner/repo' tag: 'v1.0.0' fileName: 'foo.zip' ``` ```yaml - uses: robinraju/release-downloader@v1 with: repository: 'owner/repo' latest: true tarBall: true zipBall: true ``` ```yaml - uses: robinraju/release-downloader@v1 with: repository: 'owner/repo' latest: true fileName: 'foo.zip' tarBall: true zipBall: true ``` ```yaml - uses: robinraju/release-downloader@v1 with: repository: 'owner/repo' latest: true fileName: '*' ``` ```yaml - uses: robinraju/release-downloader@v1 with: repository: 'owner/repo' latest: true fileName: '*.deb' ``` ```yaml - uses: robinraju/release-downloader@v1 with: releaseId: '123123' fileName: 'foo.zip' ``` ```yaml - uses: robinraju/release-downloader@v1 with: fileName: 'foo.zip' latest: true extract: true ``` ```yaml - uses: robinraju/release-downloader@v1 with: repository: 'owner/repo' fileName: 'foo.zip' latest: true preRelease: true ``` -------------------------------- ### Core Action Execution Logic (JavaScript) Source: https://github.com/robinraju/release-downloader/blob/main/CONTRIBUTING.md The main asynchronous function 'run' that orchestrates the action's logic. It includes a try-catch block to handle errors and uses '@actions/core' for logging and setting failure states. ```javascript import * as core from '@actions/core'; async function run() { try { // Action logic here } catch (error) { core.setFailed(error.message); } } run() ``` -------------------------------- ### Wildcard Pattern Matching for Asset Selection Source: https://context7.com/robinraju/release-downloader/llms.txt Demonstrates how to use wildcard patterns with minimatch to select specific files or groups of files from GitHub releases. This allows for flexible downloading of assets based on their names, supporting scenarios like downloading all packages of a certain type or specific build artifacts. ```yaml - uses: robinraju/release-downloader@v1 with: latest: true fileName: '*.deb' - uses: robinraju/release-downloader@v1 with: latest: true fileName: 'app-linux-' - uses: robinraju/release-downloader@v1 with: tag: 'v1.0.0' fileName: 'build-{prod,staging}-*.tar.gz' - uses: robinraju/release-downloader@v1 with: latest: true fileName: '*' ``` -------------------------------- ### Input Helper for GitHub Actions (TypeScript) Source: https://context7.com/robinraju/release-downloader/llms.txt This TypeScript code demonstrates the `getInputs` function from the `input-helper` module, used to process GitHub Actions inputs. It validates and transforms these inputs into a typed `IReleaseDownloadSettings` object. Errors during input processing are caught and reported using `@actions/core`. ```typescript import * as core from '@actions/core' import { getInputs } from './input-helper' // In GitHub Actions context try { const downloadSettings = getInputs() console.log('Repository:', downloadSettings.sourceRepoPath) console.log('Output path:', downloadSettings.outFilePath) console.log('Latest release:', downloadSettings.isLatest) } catch (error) { core.setFailed(`Configuration error: ${error.message}`) } // Error handling examples: // - Invalid repository format (not owner/repo): throws Error // - Multiple version selectors (latest + tag + id): throws Error // - Missing GITHUB_WORKSPACE environment: throws Error ``` -------------------------------- ### Download Latest Prerelease using GitHub Actions Source: https://context7.com/robinraju/release-downloader/llms.txt This GitHub Actions workflow retrieves assets from the most recent prerelease version of a repository. It's useful for testing beta or release candidate builds. Inputs include the repository, setting `latest` and `preRelease` to true, the file name, and the output path. ```yaml - name: Download beta version uses: robinraju/release-downloader@v1 with: repository: 'software/product' latest: true preRelease: true fileName: 'beta-installer.msi' out-file-path: 'beta' - name: Test beta installation run: msiexec /i beta/beta-installer.msi /qn ``` -------------------------------- ### Access release-downloader output variables in shell scripts Source: https://github.com/robinraju/release-downloader/blob/main/README.md These shell snippets show how to reference the action's outputs—tag name, release name, and downloaded files—from subsequent steps in a workflow. Use the provided interpolation syntax within a run block or other shell commands. ```sh ${{steps..outputs.tag_name}} ``` ```sh ${{steps..outputs.release_name}} ``` ```sh ${{ fromJson(steps..outputs.downloaded_files)[0] }} ``` -------------------------------- ### Download Source Code Archives (Tarball/Zipball) in YAML Source: https://context7.com/robinraju/release-downloader/llms.txt Retrieves GitHub-generated source tarball and zipball from the latest release to an output directory for extraction and building. Configures release-downloader with tarBall and zipBall flags; requires repository and latest inputs. Outputs archives only; manual extraction needed for building. ```yaml - name: Download source code uses: robinraju/release-downloader@v1 with: repository: 'opensource/project' latest: true tarBall: true zipBall: true out-file-path: 'source' - name: Extract and build from source run: | tar -xzf source/*.tar.gz -C build/ cd build/*/ make && make install ``` -------------------------------- ### Download Assets from Specific Release Tag in YAML Source: https://context7.com/robinraju/release-downloader/llms.txt Retrieves assets from a release by Git tag for version pinning, downloading a specific file like 'production-build.tar.gz' to an output directory. Uses release-downloader action; requires repository and tag inputs; supports checksum verification post-download. Cannot handle dynamic tags without workflow logic. ```yaml - name: Download production release uses: robinraju/release-downloader@v1 with: repository: 'organization/product' tag: 'v2.1.0' fileName: 'production-build.tar.gz' out-file-path: 'releases' - name: Verify checksum run: | cd releases sha256sum -c production-build.tar.gz.sha256 ``` -------------------------------- ### Download from GitHub Enterprise Server in YAML Source: https://context7.com/robinraju/release-downloader/llms.txt Configures release-downloader for GitHub Enterprise by specifying a custom API URL and token, downloading assets like executables to an output path. Inputs include repository, latest, fileName, token, and github-api-url. Supports Enterprise v3 API; requires valid Enterprise token with repo access. ```yaml - name: Download from enterprise server uses: robinraju/release-downloader@v1 with: repository: 'enterprise-org/enterprise-repo' latest: true fileName: 'enterprise-app.exe' token: ${{ secrets.ENTERPRISE_TOKEN }} github-api-url: 'https://github.enterprise.com/api/v3' out-file-path: 'downloads' ``` -------------------------------- ### IReleaseDownloadSettings Interface Definition (TypeScript) Source: https://context7.com/robinraju/release-downloader/llms.txt This TypeScript interface defines the structure for configuring release download operations. It includes parameters for source repository, version selection (latest, tag, ID), file names, archive types, extraction options, and output paths. Validation rules ensure only one version selector is used. ```typescript import { IReleaseDownloadSettings } from './download-settings' const downloadConfig: IReleaseDownloadSettings = { sourceRepoPath: 'company/product', isLatest: false, preRelease: false, tag: 'v3.2.1', id: '', fileName: 'installer-*.exe', tarBall: false, zipBall: false, extractAssets: true, outFilePath: '/var/tmp/releases' } // Validation: Only one of isLatest, tag, or id should be specified const validLatest: IReleaseDownloadSettings = { sourceRepoPath: 'user/repo', isLatest: true, preRelease: false, tag: '', // Must be empty id: '', // Must be empty fileName: '*', tarBall: false, zipBall: false, extractAssets: false, outFilePath: './output' } // Download multiple asset types const multiAsset: IReleaseDownloadSettings = { sourceRepoPath: 'org/project', isLatest: true, preRelease: false, tag: '', id: '', fileName: '*.deb', // Specific files tarBall: true, // Also download tarball zipBall: true, // And zipball extractAssets: false, outFilePath: './releases' } ``` -------------------------------- ### ReleaseDownloader Core TypeScript API for Downloads Source: https://context7.com/robinraju/release-downloader/llms.txt This TypeScript code demonstrates the core `ReleaseDownloader` class for programmatic asset downloads. It utilizes `typed-rest-client` for HTTP requests and requires a GitHub token for authentication. The `download` method takes a settings object and returns downloaded file information or throws an error on failure. ```typescript import * as handlers from 'typed-rest-client/Handlers' import * as thc from 'typed-rest-client/HttpClient' import { ReleaseDownloader } from './release-downloader' import { IReleaseDownloadSettings } from './download-settings' async function downloadRelease() { const authToken = process.env.GITHUB_TOKEN || '' const githubApiUrl = 'https://api.github.com' const credentialHandler = new handlers.BearerCredentialHandler( authToken, false ) const httpClient = new thc.HttpClient('my-app', [credentialHandler]) const downloader = new ReleaseDownloader(httpClient, githubApiUrl) const settings: IReleaseDownloadSettings = { sourceRepoPath: 'owner/repository', isLatest: true, preRelease: false, tag: '', id: '', fileName: '*.zip', tarBall: false, zipBall: false, extractAssets: false, outFilePath: './downloads' } try { const downloadedFiles = await downloader.download(settings) console.log('Successfully downloaded:', downloadedFiles) return downloadedFiles } catch (error) { console.error('Download failed:', error.message) throw error } } downloadRelease() ``` -------------------------------- ### GitHub Action Workflow Configuration for Release Downloader in YAML Source: https://context7.com/robinraju/release-downloader/llms.txt Configures the release-downloader action in a GitHub Actions workflow to download assets with parameters for repository, release selection, file patterns, extraction, and authentication. Outputs metadata like tag name, release name, and downloaded files for use in subsequent steps. Requires GITHUB_TOKEN for private repos; supports custom API URLs for Enterprise. ```yaml - name: Download release assets uses: robinraju/release-downloader@v1 id: download-step with: repository: 'owner/repo' latest: true preRelease: false tag: '' releaseId: '' fileName: '*.zip' tarBall: false zipBall: false out-file-path: 'downloads' extract: false token: ${{ secrets.GITHUB_TOKEN }} github-api-url: 'https://api.github.com' - name: Use downloaded files run: | echo "Downloaded release: ${{ steps.download-step.outputs.tag_name }}" echo "Release name: ${{ steps.download-step.outputs.release_name }}" echo "Files: ${{ steps.download-step.outputs.downloaded_files }}" ``` -------------------------------- ### Download All Release Assets with Wildcard in YAML Source: https://context7.com/robinraju/release-downloader/llms.txt Downloads every asset from a release using '*' wildcard, excluding source archives by default, to an output directory for listing and processing. Relies on release-downloader; inputs are repository, latest, fileName, and out-file-path. May download large volumes; no built-in size limits. ```yaml - name: Download all release artifacts uses: robinraju/release-downloader@v1 with: repository: 'vendor/library' latest: true fileName: '*' out-file-path: 'artifacts' - name: List downloaded files run: ls -lh artifacts/ ``` -------------------------------- ### Download Assets from Private Repository in YAML Source: https://context7.com/robinraju/release-downloader/llms.txt Downloads files from private repos using a personal access token for authentication, placing them in an output directory with executable permissions. Employs release-downloader with token input; supports latest release and fileName patterns. Requires secrets.PRIVATE_REPO_TOKEN; limited by token scopes. ```yaml - name: Download private release uses: robinraju/release-downloader@v1 with: repository: 'company/private-repo' latest: true fileName: 'internal-tool' token: ${{ secrets.PRIVATE_REPO_TOKEN }} out-file-path: 'tools' - name: Set executable permissions run: chmod +x tools/internal-tool ``` -------------------------------- ### Download and Extract Archive Assets in YAML Source: https://context7.com/robinraju/release-downloader/llms.txt Downloads an archive like 'dist.zip' from a specific tag and extracts it automatically to the output path for immediate use in running applications. Uses release-downloader with extract: true; inputs include repository, tag, fileName, and out-file-path. Supports zip, tar, tar.gz; extraction overwrites existing files. ```yaml - name: Download and extract distribution uses: robinraju/release-downloader@v1 with: repository: 'project/distribution' tag: 'v1.5.2' fileName: 'dist.zip' extract: true out-file-path: 'extracted' - name: Run extracted application run: | cd extracted ./bin/application --version ``` -------------------------------- ### Extract Function for Archive Extraction (TypeScript) Source: https://context7.com/robinraju/release-downloader/llms.txt This TypeScript code showcases the `extract` function for decompressing archives. It supports zip, tar, and tar.gz formats. The function takes the archive path and a destination directory. It logs warnings for unsupported formats and gracefully handles extraction errors. ```typescript import { extract } from './unarchive' import * as path from 'path' async function extractArchives() { const archivePath = './downloads/release-archive.tar.gz' const destinationDir = './extracted' try { await extract(archivePath, destinationDir) console.log(`Extracted ${archivePath} to ${destinationDir}`) } catch (error) { console.error('Extraction failed:', error.message) } // Extract zip file const zipPath = './downloads/source.zip' await extract(zipPath, destinationDir) // Unsupported format warning example const textFile = './downloads/readme.txt' await extract(textFile, destinationDir) // Logs warning, skips file } extractArchives() ``` -------------------------------- ### Download by Release ID using GitHub Actions Source: https://context7.com/robinraju/release-downloader/llms.txt This GitHub Actions workflow downloads a specific release asset identified by its numeric ID. It requires the repository path, release ID, desired file name, and an output path. The downloaded artifact can then be used in subsequent workflow steps. ```yaml - name: Download by release ID uses: robinraju/release-downloader@v1 with: repository: 'owner/repo' releaseId: '68092191' fileName: 'build-artifact.jar' out-file-path: 'target' - name: Deploy artifact run: |- java -jar target/build-artifact.jar ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.