Skip to content

Workflow file for this run

name: cargo b(inary)install
permissions: write-all
on:
push:
branches:
- main
tags-ignore:
- "**"
paths-ignore:
- "**/*.md"
- LICENSE
- "**/*.gitignore"
- .editorconfig
- docs/**
pull_request: null
jobs:
create-release:
name: Create a new github release
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.get-u-url.outputs.result }}
release_id: ${{ steps.get-id.outputs.result }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Create Release
id: create-release
uses: actions/github-script@v7
env:
BRANCH: ${{ github.ref_name }}
with:
script: |
const fs = require("fs");
const version = require('./package.json').version;
const { data } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: version,
name: `AHQ Store CLI v${version}`,
body: String(fs.readFileSync("./latest.md")),
draft: true,
prerelease: false
});
return data
- name: Get Release Id
id: get-id
uses: actions/github-script@v7
env:
data: ${{ steps.create-release.outputs.result }}
with:
result-encoding: string
script: |
let data = process.env.data;
try {
data = JSON.parse(data);
console.log(data.id);
return data.id;
} catch (_) {
console.log(data.id);
return data.id;
}
- name: Get Upload Url
id: get-u-url
uses: actions/github-script@v7
env:
data: ${{ steps.create-release.outputs.result }}
with:
result-encoding: string
script: |
let data = process.env.data;
try {
data = JSON.parse(data);
return data.upload_url;
} catch (_) {
return data.upload_url;
}
build:
needs: [create-release]
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
friendlyName: x86_64 Linux
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
friendlyName: Arm64 Linux
- os: ubuntu-latest
target: i686-unknown-linux-gnu
friendlyName: x86 Linux
- os: windows-latest
target: x86_64-pc-windows-msvc
friendlyName: x86_64 Windows
- os: windows-latest
target: i686-pc-windows-msvc
friendlyName: x86 Windows
- os: windows-latest
target: aarch64-pc-windows-msvc
friendlyName: Arm64 Windows
- os: macos-latest
target: x86_64-apple-darwin
friendlyName: x86_64 Macos
- os: macos-latest
target: aarch64-apple-darwin
friendlyName: Arm64 Macos
name: Build CLI for ${{ matrix.friendlyName }} (${{ matrix.os }}-${{ matrix.target }})
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust Nightly
run: rustup toolchain add nightly-${{ matrix.target }}
- name: Linux Cross Platform
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install zip gcc-aarch64-linux-gnu gcc-i686-linux-gnu
chmod 777 ./bundle
- name: Build CLI
run: cargo build --release
- name: Bundle CLI
run: ./bundle
env:
TARGET: ${{ matrix.target }}
- name: Upload to Releases
uses: AButler/[email protected]
with:
release-id: ${{ needs.create-release.outputs.release_id }}
files: ./ahqstore_cli_rs-${{ matrix.target }}.zip
repo-token: ${{ secrets.GITHUB_TOKEN }}
publish:
needs: [create-release, build]
name: Publish Release
runs-on: ubuntu-latest
steps:
- name: Undraft Release
uses: actions/github-script@v7
env:
R_ID: ${{ needs.create-release.outputs.release_id }}
with:
script: |
github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.R_ID,
draft: false
});