Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gerschtli/generate-nix-hash

Github Action to write a JSON file with rev and sha256 of given repository revision.
https://github.com/gerschtli/generate-nix-hash

actions github nix nixpkgs

Last synced: about 1 month ago
JSON representation

Github Action to write a JSON file with rev and sha256 of given repository revision.

Awesome Lists containing this project

README

        

# Generate Nix Hash
[![Github Workflow](https://github.com/Gerschtli/generate-nix-hash/workflows/build-test/badge.svg)](https://github.com/Gerschtli/generate-nix-hash/actions)

This action fetches the `.tar.gz` archive of the provided repository revision and creates a JSON file containing the revision and sha256 hash generated by `nix-prefetch-url`. As a consequence [`nix`](https://nixos.org/nix) is needed for this action as shown in the example below.

## Usage

Create `.github/workflows/test.yml` in your repo with the following contents:

```yaml
name: "Test"
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v8
- uses: Gerschtli/generate-nix-hash@v1
with:
rev: c61573364694a68d9993c8b0fb603b29e7251d79 # commit id
owner: Gerschtli
repo: generate-nix-hash
file: config.json
```

This produces a JSON file like:
```json
{
"rev": "c61573364694a68d9993c8b0fb603b29e7251d79",
"sha256": "1s0qrrin8ry9klvjaxj4hd3qlf3cayfisq8pn7idqddgcg0lc079"
}
```

See [action.yml](action.yml) for all options.

---

## Publish to a distribution branch

Actions are run from GitHub repos so we will checkin the packed dist folder.

Then run [ncc](https://github.com/zeit/ncc) and push the results:
```bash
$ npm run pack
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1
```

Your action is now published! :rocket:

See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)