Skip to content

Commit

Permalink
added logic to check for and build new lair binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
matthme committed Feb 20, 2024
1 parent 5f86b26 commit 6026227
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 10 deletions.
41 changes: 32 additions & 9 deletions .github/workflows/check-new-releases.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Check for new releases
on:
schedule:
- cron: '0 * * * *'
# on:
# push:
# branches:
# - main
# schedule:
# - cron: '0 * * * *'
on:
push:
branches:
- main

jobs:
check-new-01-releases:
Expand All @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'
- name: Check for new holochain releases
id: check_releases
run: |
Expand All @@ -38,7 +38,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'
- name: Check for new holochain releases
id: check_releases
run: |
Expand All @@ -62,7 +62,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'
- name: Check for new holochain releases
id: check_releases
run: |
Expand All @@ -78,3 +78,26 @@ jobs:
uses: ./.github/workflows/holochain-binaries.yaml
with:
holochain-version: ${{ needs.check-new-03-releases.outputs.holochain-version }}

check-new-lair-releases:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Check for new lair releases
id: check_releases
run: |
echo "lair_version=$(node ./scripts/check-new-lair-releases.mjs)" >> $GITHUB_OUTPUT
outputs:
lair-version: ${{ steps.check_releases.outputs.lair_version }}

build-lair-binaries:
permissions:
contents: write
needs: check-new-lair-releases
if: ${{ needs.check-new-lair-releases.outputs.lair-version }}
uses: ./.github/workflows/lair-binaries.yaml
with:
lair-version: ${{ needs.check-new-lair-releases.outputs.lair-version }}
73 changes: 73 additions & 0 deletions .github/workflows/lair-binaries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: 'release-lair-binaries'
on:
workflow_call:
inputs:
lair-version:
required: true
type: string
jobs:
publish-lair-binaries:
strategy:
fail-fast: false
matrix:
platform: [windows-2019, macos-11, ubuntu-22.04]
permissions:
contents: write
runs-on: ${{ matrix.platform }}

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
# Checks out a copy of your repository on the ubuntu-latest machine
- uses: actions/checkout@v4

- name: setup node
uses: actions/setup-node@v4
with:
node-version: 20

- id: create-release
uses: ncipollo/release-action@v1
with:
body: 'Lair binaries for Linux/Windows/macOS.'
prerelease: true
skipIfReleaseExists: true
tag: lair-binaries-${{ inputs.lair-version }}

- name: install Rust stable
uses: actions-rs/toolchain@v1
with:
override: true
toolchain: stable

- name: setup binaries (Windows only)
if: matrix.platform == 'windows-2019'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo install lair_keystore --version ${{ inputs.lair-version }}
$LkPath = Get-Command lair-keystore | Select-Object -ExpandProperty Definition
Copy-Item $LkPath -Destination "lair-keystore-v{{ inputs.lair-version }}-x86_64-pc-windows-msvc.exe"
gh release upload "lair-binaries-${{ inputs.lair-version }}" "lair-keystore-v${{ inputs.lair-version }}-x86_64-pc-windows-msvc.exe"
- name: setup binaries (macos only)
if: matrix.platform == 'macos-11'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo install lair_keystore --version ${{ inputs.lair-version }}
LAIR_PATH=$(which lair-keystore)
cp $LAIR_PATH lair-keystore-v${{ inputs.lair-version }}-x86_64-apple-darwin
gh release upload "lair-binaries-${{ inputs.lair-version }}" "lair-keystore-v${{ inputs.lair-version }}-x86_64-apple-darwin"
- name: setup binaries (ubuntu only)
if: matrix.platform == 'ubuntu-22.04'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo install lair_keystore --version ${{ inputs.lair-version }}
LAIR_PATH=$(which lair-keystore)
cp $LAIR_PATH lair-keystore-v${{ inputs.lair-version }}-x86_64-unknown-linux-gnu
gh release upload "lair-binaries-${{ inputs.lair-version }}" "lair-keystore-v${{ inputs.lair-version }}-x86_64-unknown-linux-gnu"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# holochain-binaries

This repo builds the holochain binaries for Linux/macOS/Windows.
This repo automatically builds the holochain and lair binaries for Linux/macOS/Windows.



52 changes: 52 additions & 0 deletions scripts/check-new-lair-releases.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import https from 'https';

const lairCrateOptions = {
hostname: 'crates.io',
port: 443,
path: '/api/v1/crates/lair_keystore',
method: 'GET',
headers: {
'User-Agent': 'Holochain Binaries'
}
};

const binariesTagsOptions = {
hostname: 'api.github.com',
port: 443,
path: '/repos/matthme/holochain-binaries/tags',
method: 'GET',
headers: {
'User-Agent': 'Holochain Binaries'
}
}

getAndDo(lairCrateOptions, (data) => {
const lairCrateDetails = JSON.parse(data);
const latestLairVersion = lairCrateDetails.crate.newest_version;
getAndDo(binariesTagsOptions, (data) => {
const binaryTags = JSON.parse(data);
// Check whether the latest lair_keystore crate version already has a tag in the holochain-binaries repo. If not, log it to the console
const binaryTagLairVersions = binaryTags.filter((tag) => tag.name.includes('lair-binaries')).map((tag) => tag.name.replace('lair-binaries-', ''));
if (!binaryTagLairVersions.includes(latestLairVersion)) {
console.log(latestLairVersion);
}
})
})


function getAndDo(options, callback) {
https.get(options, (res) => {
let data = '';

res.on('data', (chunk) => {
data += chunk;
});

res.on('end', () => {
callback(data);
});

}).on('error', (err) => {
console.log("Error: ", err.message);
})
}

0 comments on commit 6026227

Please sign in to comment.