Release #37
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
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
semver-bump: | |
description: Semver bump release type | |
required: true | |
type: choice | |
default: patch | |
options: | |
- major | |
- minor | |
- patch | |
concurrency: publish | |
jobs: | |
# verified: | |
# uses: ./.github/workflows/verify.yml | |
publish-cargo-crate: | |
# needs: verified | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Cargo semver bump | |
id: semver | |
env: | |
SEMVER_BUMP: ${{github.event.inputs.semver-bump}} | |
run: | | |
cargo install cargo-release | |
cargo release version $SEMVER_BUMP --no-confirm --execute | |
VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2) }' Cargo.toml) | |
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
# - name: Cargo publish | |
# env: | |
# CARGO_REGISTRY_TOKEN: ${{secrets.CRATES_IO_API_TOKEN}} | |
# 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]" | |
VERSION=${{steps.semver.outputs.version}} | |
BRANCH_NAME=bump-semver-$VERSION | |
git checkout -b $BRANCH_NAME | |
git commit -am "increment Cargo.toml version to $VERSION" | |
git push origin $BRANCH_NAME | |
gh pr create --base main --title "cargo publish $VERSION" --body "cargo publish $VERSION" | |
gh pr merge $BRANCH_NAME --auto --rebase | |
outputs: | |
version: ${{steps.semver.outputs.version}} | |
# push-docker-image: | |
# needs: publish-cargo-crate | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - uses: docker/login-action@v3 | |
# with: | |
# username: 84tech | |
# password: ${{secrets.DOCKERHUB_TOKEN}} | |
# - name: docker | |
# env: | |
# 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-release: | |
runs-on: ubuntu-22.04 | |
needs: publish-cargo-crate | |
steps: | |
- name: Create release | |
id: create | |
env: | |
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/cquill/releases \ | |
-f tag_name="$VERSION" \ | |
-f name="$VERSION" \ | |
-f body="$VERSION release" \ | |
-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}} | |
upload_hostname: ${{steps.create.outputs.upload_hostname}} | |
publish-artifact-linux-arm64: | |
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: 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: | |
- cpu: aarch64 | |
- cpu: x86_64 | |
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-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 $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-windows: | |
runs-on: windows-2022 | |
needs: | |
- publish-cargo-crate | |
- create-release | |
strategy: | |
matrix: | |
include: | |
- 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: | |
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-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 | |
#gh release upload $env:TAG $Filename | |
cleanup-release-failure: | |
runs-on: ubuntu-22.04 | |
needs: | |
- 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 release | |
env: | |
RELEASE_ID: ${{needs.create-release.outputs.release_id}} | |
GH_TOKEN: ${{secrets.GH_TOKEN}} | |
run: | | |
gh api \ | |
--method DELETE \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
/repos/eighty4/cquill/releases/$RELEASE_ID |