-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from BowTiedDevOps/ci/move-checksum-step-to-co…
…mposite Move Checksum Step to Composite
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generate Checksum action | ||
|
||
Generates a 512-bit `sha` hash for each file downloaded from artifacts. | ||
|
||
## Documentation | ||
|
||
### Inputs | ||
|
||
| Input | Description | Required | Default | | ||
| ------------------------------- | ----------------------------------------------------- | ------------------------- | ------------------------- | | ||
| `hashfile_name` | The name of the generated checksum file | false | "CHECKSUMS.txt" | | ||
|
||
## Usage | ||
|
||
```yaml | ||
name: Action | ||
on: push | ||
jobs: | ||
build: | ||
name: Job | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Generate Checksum | ||
id: generate_checksum | ||
uses: stacks-network/actions/generate-checksum@main | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
## Github workflow to generate a sha512 checksum for the build archive | ||
name: Generate Checksum | ||
|
||
inputs: | ||
hashfile_name: | ||
description: "The name of the generated checksum file" | ||
required: false | ||
default: "CHECKSUMS.txt" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
## Downloads the artifacts built in `create-source-binary.yml` | ||
- name: Download Artifacts | ||
id: download_artifacts | ||
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | ||
with: | ||
name: artifact | ||
path: release | ||
|
||
## Generate a checksums file to be added to the release page | ||
- name: Generate Checksums | ||
id: generate_checksum | ||
shell: bash | ||
run: | | ||
# If sha512sum command doesn't exist on the host, exit | ||
if ! command -v sha512sum > /dev/null 2>&1; then | ||
echo "sha512sum command doesn't exist!"; | ||
exit 1; | ||
fi | ||
# Generate the hashes and exit if the variable is empty | ||
shasum="$(sha512sum release/*)" | ||
if [[ -z "$shasum" ]]; then | ||
echo "Checksum could not be generated!"; | ||
exit 1; | ||
fi | ||
echo "Generated checksums:" | ||
echo "$shasum" | ||
echo "$shasum" > "${{ inputs.hashfile_name }}"; | ||
exit 0; |