Skip to content

Commit

Permalink
Merge pull request #24 from BowTiedDevOps/ci/move-checksum-step-to-co…
Browse files Browse the repository at this point in the history
…mposite

Move Checksum Step to Composite
  • Loading branch information
wileyj authored Feb 15, 2024
2 parents aed0417 + 9692e1e commit ab70cdb
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Monorepo of [composite actions](https://docs.github.com/en/actions/creating-acti
- [codecov](./cleanup) - Uploads codecov reports with a retry if it fails (optionally it can run grcov to generate a report to send)
- [openapi](./cleanup) - Generates and uploads an [OpenAPI](https://spec.openapis.org/oas/latest.html) artifact
- [docker](./docker) - Generic Docker setup workflows
- [generate-checksum](./generate-checksum/) - Generate a 512-bit `sha` hash of the uploaded artifacts
- [stacks-core](./stacks-core/) - actions for the [stacks-core](https://github.com/stacks-network/stacks-core) repo

## Why does this exist?
Expand Down
26 changes: 26 additions & 0 deletions generate-checksum/README.md
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
```
42 changes: 42 additions & 0 deletions generate-checksum/action.yml
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;

0 comments on commit ab70cdb

Please sign in to comment.