This GitHub action can create DotSlash files for
executables that you have published as part of a GitHub release.
The newly generated DotSlash files will be added to the existing release.
This action is designed to run after the GitHub Actions workflows that are responsible for
uploading your primary release artifacts via gh release upload or equivalent.
Example
If you had separate workflows for each platform such as linux-release,
macos-release, and windows-release, then you could define a new GitHub
action under .github/workflows/dotslash.yml as follows:
name: Generate DotSlash files
on:
workflow_run:
# These must match the names of the workflows that publish
# artifacts to your GitHub release.
workflows: [linux-release, macos-release, windows-release]
types:
- completed
jobs:
generate-dotslash-files:
name: Generating and uploading DotSlash files
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: facebook/dotslash-publish-release@v1
# This is necessary because the action uses
# `gh release upload` to publish the generated DotSlash file(s)
# as part of the release.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Additional file that lives in your repo that defines
# how your DotSlash file(s) should be generated.
config: .github/workflows/dotslash-config.json
# Tag for the release to to target.
tag: ${{ github.event.workflow_run.head_branch }}
Note the config line that specifies a path to a JSON file in your repo that
determines what DotSlash files to generate. For example, if this GitHub action
were defined in the facebook/hermes
repository on GitHub, and the contents of
.github/workflows/dotslash-config.json were as follows:
Note that each entry in platforms in the dotslash-config.json is reflected
in the platforms section of the generated DotSlash file. Each config entry
takes a "name" or a "regex" to use to identify the appropriate artifact in
the release and the "path" indicates the "path" that should be used for the
artifact in the generated DotSlash file.
The dotslash-publish-release action defaults to using BLAKE3 as the hash
function, so it takes responsibility for computing the size and digest
values. It also tries to “guess” the appropriate value of "format" based on
the suffix of the URL, though this can also be specified explicitly, which is a
bit safer:
By default, dotslash-publish-release generates both the HTTP provider as well
as the github-release provider for each entry in the DotSlash file. Either of
these can be disabled via top-level "exclude-http-provider" and
"exclude-github-release-provider" properties, respectively. For example, if
you are using this action in a private GitHub repo, then you probably want to
disable the HTTP provider:
The most important part of the config file is the top-level "outputs" entry.
Each key in this entry will be the name of the generated DotSlash file that is
added to the release.
Each platform entry recognizes the following properties:
One of regex or name is required to identify the file in the release that
should be used as the DotSlash artifact for the platform.
path is required and is used as the corresponding path value in the
DotSlash file.
format is optional, but recommended. It must be a valid DotSlash artifact
format, such as
tar.gz. If the artifact is not compressed, then "format": null must be
specified explicitly in the config JSON.
hash must be one of "blake3" or "sha256", but it defaults to "blake3",
so it is optional.
Action Inputs
This action supports the following inputs:
config (required): Path to .json file in the repo that defines how DotSlash files should be generated.
tag (required): Tag identifying the release whose assets should be used.
include-build-metadata (optional): Whether to include build metadata in the generated DotSlash files. Defaults to true.
Build Metadata
By default, the action embeds build metadata in the generated DotSlash files to provide traceability about how and when the files were generated. This metadata includes:
Source configuration: Path to the config file used to generate the DotSlash file
CI information: Repository, commit SHA, run ID, workflow name, actor, and event type
Generation timestamp: When the DotSlash file was generated
CI job URL: Direct link to the GitHub Actions run that generated the file
dotslash-publish-release
This GitHub action can create DotSlash files for executables that you have published as part of a GitHub release. The newly generated DotSlash files will be added to the existing release.
This action is designed to run after the GitHub Actions workflows that are responsible for uploading your primary release artifacts via
gh release uploador equivalent.Example
If you had separate workflows for each platform such as
linux-release,macos-release, andwindows-release, then you could define a new GitHub action under.github/workflows/dotslash.ymlas follows:Note the
configline that specifies a path to a JSON file in your repo that determines what DotSlash files to generate. For example, if this GitHub action were defined in the facebook/hermes repository on GitHub, and the contents of.github/workflows/dotslash-config.jsonwere as follows:Then this action would have added the following DotSlash file named
hermesto the v0.12.0 release:Note that each entry in
platformsin thedotslash-config.jsonis reflected in theplatformssection of the generated DotSlash file. Each config entry takes a"name"or a"regex"to use to identify the appropriate artifact in the release and the"path"indicates the"path"that should be used for the artifact in the generated DotSlash file.The
dotslash-publish-releaseaction defaults to using BLAKE3 as the hash function, so it takes responsibility for computing thesizeanddigestvalues. It also tries to “guess” the appropriate value of"format"based on the suffix of the URL, though this can also be specified explicitly, which is a bit safer:By default,
dotslash-publish-releasegenerates both the HTTP provider as well as thegithub-releaseprovider for each entry in the DotSlash file. Either of these can be disabled via top-level"exclude-http-provider"and"exclude-github-release-provider"properties, respectively. For example, if you are using this action in a private GitHub repo, then you probably want to disable the HTTP provider:The generated DotSlash file would reflect this change:
Config File Details
The most important part of the config file is the top-level
"outputs"entry. Each key in this entry will be the name of the generated DotSlash file that is added to the release.The
"platforms"map for each entry requires that the keys are platforms that are recognized by DotSlash.Each platform entry recognizes the following properties:
regexornameis required to identify the file in the release that should be used as the DotSlash artifact for the platform.pathis required and is used as the correspondingpathvalue in the DotSlash file.formatis optional, but recommended. It must be a valid DotSlash artifact format, such astar.gz. If the artifact is not compressed, then"format": nullmust be specified explicitly in the config JSON.hashmust be one of"blake3"or"sha256", but it defaults to"blake3", so it is optional.Action Inputs
This action supports the following inputs:
config(required): Path to .json file in the repo that defines how DotSlash files should be generated.tag(required): Tag identifying the release whose assets should be used.include-build-metadata(optional): Whether to include build metadata in the generated DotSlash files. Defaults totrue.Build Metadata
By default, the action embeds build metadata in the generated DotSlash files to provide traceability about how and when the files were generated. This metadata includes:
Example of embedded metadata:
To disable build metadata inclusion, set
include-build-metadatatofalse:License
dotslash-publish-release is MIT licensed.