-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adam McKee
committed
Dec 20, 2024
1 parent
1013aec
commit cba1d17
Showing
5 changed files
with
237 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: [ '*' ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
# verify: | ||
# uses: ./.github/workflows/verify.yml | ||
|
||
publish-cargo-crates: | ||
runs-on: ubuntu-latest | ||
# needs: verify | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# - uses: dtolnay/rust-toolchain@stable | ||
# - uses: swatinem/rust-cache@v2 | ||
# - run: cargo install cargo-release | ||
# - run: cargo release --no-confirm -x patch | ||
- id: version | ||
run: | | ||
VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2) }' l3_cli/Cargo.toml) | ||
TAG_NAME="l3_cli-v$VERSION" | ||
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT" | ||
outputs: | ||
tag_name: ${{ steps.version.outputs.tag_name }} | ||
version: ${{ steps.version.outputs.version }} | ||
|
||
create-gh-release: | ||
runs-on: ubuntu-22.04 | ||
needs: publish-cargo-crates | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Create release | ||
id: create | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
TAG_NAME: ${{ needs.publish-cargo-crates.outputs.tag_name }} | ||
VERSION: ${{ needs.publish-cargo-crates.outputs.version }} | ||
run: | | ||
NOTES=$(cat l3_cli/CHANGELOG.md | awk -v p="## $VERSION" -F":" '$0 ~ p{f=1;next} /## /{f=0} f') | ||
CREATED_RELEASE=$(gh api \ | ||
--method POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
/repos/eighty4/l3/releases \ | ||
-f tag_name="$TAG_NAME" \ | ||
-f name="CLI v$VERSION" \ | ||
-F body="Release notes\n\n$NOTES" \ | ||
-F draft=false \ | ||
-F prerelease=false \ | ||
-F generate_release_notes=false) | ||
echo "release_id=$(echo $CREATED_RELEASE | jq '.id')" >> "$GITHUB_OUTPUT" | ||
echo "upload_hostname=$(echo $CREATED_RELEASE | jq '.upload_url' | cut -d'/' -f3)" >> "$GITHUB_OUTPUT" | ||
outputs: | ||
release_id: ${{ steps.create.outputs.release_id }} | ||
tag_name: ${{ needs.publish-cargo-crates.outputs.tag_name }} | ||
upload_hostname: ${{ steps.create.outputs.upload_hostname }} | ||
|
||
upload-gh-asset-linux-and-macos: | ||
needs: create-gh-release | ||
uses: ./.github/workflows/gh_release_upload.yml | ||
with: | ||
release_id: ${{ needs.create-gh-release.outputs.release_id }} | ||
tag_name: ${{ needs.create-gh-release.outputs.tag_name }} | ||
upload_hostname: ${{ needs.create-gh-release.outputs.upload_hostname }} | ||
secrets: inherit | ||
|
||
upload-gh-asset-l3-windows: | ||
needs: create-gh-release | ||
uses: ./.github/workflows/gh_release_upload_windows.yml | ||
with: | ||
release_id: ${{ needs.create-gh-release.outputs.release_id }} | ||
tag_name: ${{ needs.create-gh-release.outputs.tag_name }} | ||
upload_hostname: ${{ needs.create-gh-release.outputs.upload_hostname }} | ||
secrets: inherit |
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,61 @@ | ||
name: Upload Linux/MacOS | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
release_id: | ||
required: true | ||
type: string | ||
tag_name: | ||
required: true | ||
type: string | ||
upload_hostname: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
|
||
upload-gh-asset: | ||
runs-on: ${{ matrix.runner }} | ||
strategy: | ||
matrix: | ||
include: | ||
- filename: l3-linux-x86_64 | ||
runner: ubuntu-24.04 | ||
target: x86_64-unknown-linux-gnu | ||
- filename: l3-linux-aarch64 | ||
runner: ubuntu-24.04 | ||
target: aarch64-unknown-linux-gnu | ||
apt_package_linker: gcc-aarch64-linux-gnu | ||
- filename: l3-macos-x86_64 | ||
runner: macos-latest | ||
target: x86_64-apple-darwin | ||
- filename: l3-macos-aarch64 | ||
runner: macos-latest | ||
target: aarch64-apple-darwin | ||
env: | ||
FILENAME: ${{ matrix.filename }} | ||
TARGET: ${{ matrix.target }} | ||
RELEASE_ID: ${{ inputs.release_id }} | ||
UPLOAD_HOSTNAME: ${{ inputs.upload_hostname }} | ||
steps: | ||
- if: ${{ matrix.apt_package_linker }} | ||
run: sudo apt update && sudo apt install ${{ matrix.apt_package_linker }} | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.tag_name }} | ||
- run: rustup install stable | ||
- run: rustup target add $TARGET | ||
- name: build | ||
run: cargo build --release --target $TARGET | ||
- name: upload | ||
run: | | ||
curl --fail --silent -L -X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer $GH_TOKEN" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
-H "Content-Type: $(file target/$TARGET/release/l3 -b --mime-type)" \ | ||
https://$UPLOAD_HOSTNAME/repos/eighty4/l3/releases/$RELEASE_ID/assets?name=$FILENAME \ | ||
--data-binary "@target/$TARGET/release/l3" | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} |
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,46 @@ | ||
name: Upload Windows | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
release_id: | ||
required: true | ||
type: string | ||
tag_name: | ||
required: true | ||
type: string | ||
upload_hostname: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
|
||
upload-windows-asset: | ||
runs-on: windows-2022 | ||
strategy: | ||
matrix: | ||
include: | ||
- filename: l3-windows-aarch64.exe | ||
target: aarch64-pc-windows-msvc | ||
- filename: l3-windows-x86_64.exe | ||
target: x86_64-pc-windows-msvc | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# with: | ||
# ref: ${{ inputs.tag_name }} | ||
- run: rustup install stable | ||
- run: rustup target add ${{ matrix.target }} | ||
- name: build | ||
shell: powershell | ||
run: cargo build -p l3_cli --release --target ${{ matrix.target }} | ||
- name: upload | ||
shell: powershell | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
RELEASE_ID: ${{ inputs.release_id }} | ||
UPLOAD_HOSTNAME: ${{ inputs.upload_hostname }} | ||
run: | | ||
Move-Item -Path target\${{ matrix.target }}\release\l3.exe -Destination ${{ matrix.filename }} | ||
Move-Item -Path .github/workflows/windows_upload_asset.mjs -Destination upload_asset.mjs | ||
npm i @octokit/core | ||
node upload_asset.mjs eighty4 l3 $env:RELEASE_ID ${{ matrix.filename }} application/x-dosexec $env:UPLOAD_HOSTNAME |
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,32 @@ | ||
const owner = process.argv[2] | ||
const repo = process.argv[3] | ||
const releaseId = process.argv[4] | ||
const filename = process.argv[5] | ||
const contentType = process.argv[6] | ||
const baseUrl = 'https://' + process.argv[7] | ||
|
||
import {Octokit} from '@octokit/core' | ||
|
||
const auth = process.env.GH_TOKEN | ||
|
||
const url = `POST /repos/${owner}/${repo}/releases/${releaseId}/assets?name=${filename}` | ||
|
||
const options = { | ||
baseUrl, | ||
owner, | ||
repo, | ||
release_id: releaseId, | ||
data: '@' + filename, | ||
headers: { | ||
'Accept': 'application/vnd.github+json', | ||
'Content-Type': contentType, | ||
'X-GitHub-Api-Version': '2022-11-28', | ||
}, | ||
} | ||
|
||
new Octokit({auth}).request(url, options) | ||
.then(() => console.log('finished')) | ||
.catch((e) => { | ||
console.error(e) | ||
process.exit(1) | ||
}) |