-
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.
- Loading branch information
Adam McKee
committed
Apr 15, 2024
1 parent
7f077e8
commit 2bdf926
Showing
4 changed files
with
173 additions
and
54 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 |
---|---|---|
|
@@ -20,8 +20,7 @@ jobs: | |
verified: | ||
uses: ./.github/workflows/verify.yml | ||
|
||
release: | ||
name: Publish to crates.io | ||
publish-cargo-crate: | ||
needs: verified | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -39,9 +38,10 @@ jobs: | |
- name: Cargo publish | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{secrets.CRATES_IO_API_TOKEN}} | ||
run: | | ||
cargo publish --allow-dirty | ||
run: cargo publish --allow-dirty | ||
- name: Bump ver > git | ||
env: | ||
GH_TOKEN: ${{secrets.GH_TOKEN}} | ||
run: | | ||
git config --global user.name "Adam McKee" | ||
git config --global user.email "[email protected]" | ||
|
@@ -55,38 +55,38 @@ jobs: | |
outputs: | ||
version: ${{steps.semver.outputs.version}} | ||
|
||
docker: | ||
name: Docker build and push | ||
needs: release | ||
push-docker-image: | ||
needs: publish-cargo-crate | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: docker/login-action@v2 | ||
- uses: docker/login-action@v3 | ||
with: | ||
username: 84tech | ||
password: ${{secrets.DOCKERHUB_TOKEN}} | ||
- name: docker | ||
env: | ||
VERSION: ${{needs.release.outputs.version}} | ||
VERSION: ${{needs.publish-cargo-crate.outputs.version}} | ||
run: | | ||
docker build -t 84tech/cquill --build-arg CQUILL_VERSION=$VERSION -f cquill.install.Dockerfile . | ||
docker tag 84tech/cquill 84tech/cquill:$VERSION | ||
docker push -a 84tech/cquill | ||
create-gh-release: | ||
create-release: | ||
runs-on: ubuntu-22.04 | ||
needs: release | ||
needs: publish-cargo-crate | ||
steps: | ||
- name: Create release | ||
id: create | ||
env: | ||
VERSION: ${{needs.release.outputs.version}} | ||
GH_TOKEN: ${{secrets.GH_TOKEN}} | ||
VERSION: ${{needs.publish-cargo-crate.outputs.version}} | ||
run: | | ||
CREATED_RELEASE=$(gh api \ | ||
--method POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
/repos/eighty4/maestro/releases \ | ||
/repos/eighty4/cquill/releases \ | ||
-f tag_name="$VERSION" \ | ||
-f name="$VERSION" \ | ||
-f body="$VERSION release" \ | ||
|
@@ -95,79 +95,166 @@ jobs: | |
-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}} | ||
upload_hostname: ${{steps.create.outputs.upload_hostname}} | ||
|
||
publish-gh-artifacts: | ||
publish-artifact-linux-arm64: | ||
runs-on: ubuntu-22.04 | ||
needs: create-gh-release | ||
needs: | ||
- publish-cargo-crate | ||
- create-release | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: swatinem/rust-cache@v2 | ||
- name: install cross | ||
run: cargo install cross --git https://github.com/cross-rs/cross | ||
- name: build | ||
env: | ||
TAG: ${{needs.publish-cargo-crate.outputs.version}} | ||
GH_TOKEN: ${{secrets.GH_TOKEN}} | ||
RELEASE_ID: ${{needs.create-release.outputs.release_id}} | ||
UPLOAD_HOSTNAME: ${{needs.create-release.outputs.upload_hostname}} | ||
run: | | ||
FILENAME=cquill-linux-aarch64 | ||
TARGET=aarch64-unknown-linux-gnu | ||
rustup target add $TARGET | ||
cross build --release --target $TARGET | ||
mv target/$TARGET/release/cquill $FILENAME | ||
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 $FILENAME -b --mime-type)" \ | ||
https://$UPLOAD_HOSTNAME/repos/eighty4/cquill/releases/$RELEASE_ID/assets?name=$FILENAME \ | ||
--data-binary "@$FILENAME" | ||
#gh release upload $TAG $FILENAME | ||
|
||
publish-artifact-linux-amd64: | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- publish-cargo-crate | ||
- create-release | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: swatinem/rust-cache@v2 | ||
- name: build | ||
env: | ||
TAG: ${{needs.publish-cargo-crate.outputs.version}} | ||
GH_TOKEN: ${{secrets.GH_TOKEN}} | ||
RELEASE_ID: ${{needs.create-release.outputs.release_id}} | ||
UPLOAD_HOSTNAME: ${{needs.create-release.outputs.upload_hostname}} | ||
run: | | ||
FILENAME=cquill-linux-x86_64 | ||
TARGET=x86_64-unknown-linux-gnu | ||
rustup target add $TARGET | ||
cargo build --release --target $TARGET | ||
mv target/$TARGET/release/cquill $FILENAME | ||
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 $FILENAME -b --mime-type)" \ | ||
https://$UPLOAD_HOSTNAME/repos/eighty4/cquill/releases/$RELEASE_ID/assets?name=$FILENAME \ | ||
--data-binary "@$FILENAME" | ||
#gh release upload $TAG $FILENAME | ||
|
||
publish-artifacts-macos: | ||
runs-on: macos-14 | ||
needs: | ||
- publish-cargo-crate | ||
- create-release | ||
strategy: | ||
matrix: | ||
include: | ||
- target: aarch64-apple-darwin | ||
- target: x86_64-apple-darwin | ||
- target: aarch64-unknown-linux-gnu | ||
- target: x86_64-unknown-linux-gnu | ||
- cpu: aarch64 | ||
- cpu: x86_64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: swatinem/rust-cache@v2 | ||
- name: build | ||
env: | ||
RELEASE_ID: ${{needs.create-gh-release.outputs.release_id}} | ||
UPLOAD_HOSTNAME: ${{needs.create-gh-release.outputs.upload_hostname}} | ||
GITHUB_TOKEN: ${{secrets.GH_TOKEN}} | ||
TAG: ${{needs.publish-cargo-crate.outputs.version}} | ||
GH_TOKEN: ${{secrets.GH_TOKEN}} | ||
RELEASE_ID: ${{needs.create-release.outputs.release_id}} | ||
UPLOAD_HOSTNAME: ${{needs.create-release.outputs.upload_hostname}} | ||
run: | | ||
rustup target add ${{matrix.target}} | ||
cargo build --release --target ${{matrix.target}} | ||
FILENAME=cquill-darwin-${{matrix.cpu}} | ||
TARGET=${{matrix.cpu}}-apple-darwin | ||
rustup target add $TARGET | ||
cargo build --release --target $TARGET | ||
mv target/$TARGET/release/cquill $FILENAME | ||
curl --fail --silent -L -X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer $GITHUB_TOKEN"\ | ||
-H "Authorization: Bearer $GH_TOKEN"\ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
-H "Content-Type: $(file target/release/cquill -b --mime-type)" \ | ||
https://$UPLOAD_HOSTNAME/repos/eighty4/maestro/releases/$RELEASE_ID/assets?name=cquill \ | ||
--data-binary "@target/release/cquill" | ||
-H "Content-Type: $(file $FILENAME -b --mime-type)" \ | ||
https://$UPLOAD_HOSTNAME/repos/eighty4/cquill/releases/$RELEASE_ID/assets?name=$FILENAME \ | ||
--data-binary "@$FILENAME" | ||
#gh release upload $TAG $FILENAME | ||
|
||
publish-gh-artifacts-windows: | ||
publish-artifacts-windows: | ||
runs-on: windows-2022 | ||
needs: create-gh-release | ||
needs: | ||
- publish-cargo-crate | ||
- create-release | ||
strategy: | ||
matrix: | ||
include: | ||
- target: aarch64-pc-windows-msvc | ||
- target: x86_64-pc-windows-msvc | ||
- cpu: aarch64 | ||
- cpu: x86_64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: swatinem/rust-cache@v2 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- name: build | ||
shell: powershell | ||
env: | ||
RELEASE_ID: ${{needs.create-gh-release.outputs.release_id}} | ||
UPLOAD_HOSTNAME: ${{needs.create-gh-release.outputs.upload_hostname}} | ||
GITHUB_TOKEN: ${{secrets.GH_TOKEN}} | ||
TAG: ${{needs.publish-cargo-crate.outputs.version}} | ||
GH_TOKEN: ${{secrets.GH_TOKEN}} | ||
RELEASE_ID: ${{needs.create-release.outputs.release_id}} | ||
UPLOAD_HOSTNAME: ${{needs.create-release.outputs.upload_hostname}} | ||
run: | | ||
rustup target add ${{matrix.target}} | ||
cargo build --release --target ${{matrix.target}} | ||
curl --fail --silent -L -X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer $GITHUB_TOKEN"\ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
-H "Content-Type: $(file target/release/cquill.exe -b --mime-type)" \ | ||
https://$UPLOAD_HOSTNAME/repos/eighty4/maestro/releases/$RELEASE_ID/assets?name=cquill.exe \ | ||
--data-binary "@target/release/cquill.exe" | ||
$Filename = "cquill-windows-${{matrix.cpu}}.exe" | ||
$Target = "${{matrix.cpu}}-pc-windows-msvc" | ||
rustup target add $Target | ||
cargo build --release --target $Target | ||
Move-Item -Path target\$Target\release\cquill.exe -Destination $Filename | ||
Move-Item -Path .github/workflows/upload_asset.mjs -Destination upload_asset.mjs | ||
npm i @octokit/core | ||
node upload_asset.mjs eighty4 cquill $env:RELEASE_ID $Filename application/x-dosexec $env:UPLOAD_HOSTNAME | ||
#gh release upload $env:TAG $Filename | ||
|
||
delete-failed-gh-release: | ||
cleanup-release-failure: | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- publish-gh-artifacts | ||
- publish-gh-artifacts-windows | ||
if: ${{always() && (contains(needs.publish-gh-artifacts.result, 'failure') || contains(needs.publish-gh-artifacts-windows.result, 'failure'))}} | ||
- publish-cargo-crate | ||
- create-release | ||
- publish-artifact-linux-amd64 | ||
- publish-artifact-linux-arm64 | ||
- publish-artifacts-macos | ||
- publish-artifacts-windows | ||
if: ${{always() && (contains(needs.publish-artifact-linux-amd64.result, 'failure') || contains(needs.publish-artifact-linux-arm64.result, 'failure') || contains(needs.publish-artifacts-macos.result, 'failure') || contains(needs.publish-artifacts-windows.result, 'failure'))}} | ||
steps: | ||
- name: delete failed release | ||
- name: delete release | ||
env: | ||
RELEASE_ID: ${{needs.create-gh-release.outputs.release_id}} | ||
GITHUB_TOKEN: ${{secrets.GH_TOKEN}} | ||
RELEASE_ID: ${{needs.create-release.outputs.release_id}} | ||
GH_TOKEN: ${{secrets.GH_TOKEN}} | ||
TAG: ${{needs.publish-cargo-crate.outputs.version}} | ||
run: | | ||
gh api \ | ||
--method DELETE \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
/repos/eighty4/maestro/releases/$RELEASE_ID | ||
/repos/eighty4/cquill/releases/$RELEASE_ID | ||
git push --delete origin $TAG |
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) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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