-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added logic to check for and build new lair binaries
- Loading branch information
Showing
4 changed files
with
158 additions
and
10 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,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" |
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 |
---|---|---|
@@ -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. | ||
|
||
|
||
|
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,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); | ||
}) | ||
} |