fix(cd): fix release body generation #82
Workflow file for this run
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 checks out the code, and compiles and uploads the binaries. | |
name: Continuous Deployment | |
on: | |
push: | |
branches: ["main"] | |
tags: | |
- "v*" | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: "full" | |
concurrency: | |
group: CD-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
crates-io-publish: | |
name: Publish to crates.io | |
if: startsWith(github.ref, 'refs/tags/') | |
strategy: | |
matrix: | |
crate: | |
[ | |
surrealqlx-macros-impl, | |
surrealqlx-macros, | |
surrealqlx, | |
one-or-many, | |
mecomp-analysis, | |
mecomp-storage, | |
mecomp-core, | |
mecomp-daemon, | |
mecomp-cli, | |
mecomp-tui, | |
] | |
max-parallel: 1 | |
runs-on: ubuntu-latest | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Setup cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Install cargo-hakari | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-hakari | |
- name: Publish to crates.io | |
run: cargo hakari publish --package ${{ matrix.crate }} --token=$CARGO_REGISTRY_TOKEN | |
build: | |
name: Build - ${{ matrix.binary}} for ${{ matrix.platform.os_name }} | |
strategy: | |
matrix: | |
binary: [mecomp-tui, mecomp-cli, mecomp-daemon] | |
platform: | |
- os_name: Linux-x86_64 | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- os_name: Windows-x86_64 | |
os: windows-latest | |
target: x86_64-pc-windows-msvc | |
# NOTE: once surrealdb-jsonwebtoken no longer depends on ring 0.16, we can re-add this | |
# - os_name: Windows-aarch64 | |
# os: windows-latest | |
# target: aarch64-pc-windows-msvc | |
- os_name: macOS-x86_64 | |
os: macOS-latest | |
target: x86_64-apple-darwin | |
- os_name: macOS-aarch64 | |
os: macOS-latest | |
target: aarch64-apple-darwin | |
runs-on: ${{ matrix.platform.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.platform.target }} | |
# - name: Install musl-tools on Linux | |
# run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools musl-dev | |
# if: contains(matrix.platform.os, 'ubuntu') | |
- name: Install linux dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y --no-install-recommends libasound2-dev pkg-config wget libavutil-dev libavformat-dev | |
if: contains(matrix.platform.os, 'ubuntu') | |
- name: Setup cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Build binary (Linux) | |
shell: bash | |
run: | | |
PKG_CONFIG_SYSROOT_DIR=/ cargo build --locked --release --target ${{ matrix.platform.target }} --package ${{ matrix.binary}} --bin ${{ matrix.binary }} | |
if: ${{ contains(matrix.platform.os, 'ubuntu') }} | |
- name: Build binary (macOS) | |
run: | | |
cargo build --locked --release --target ${{ matrix.platform.target }} --package ${{ matrix.binary}} --bin ${{ matrix.binary }} | |
if: ${{ contains(matrix.platform.os, 'macOS') }} | |
- name: Build binary (Windows) | |
# We have to use the platform's native shell. If we use bash on | |
# Windows then OpenSSL complains that the Perl it finds doesn't use | |
# the platform's native paths and refuses to build. | |
shell: powershell | |
run: | | |
& cargo build --locked --release --target ${{ matrix.platform.target }} --package ${{ matrix.binary}} --bin ${{ matrix.binary }} | |
if: contains(matrix.platform.os, 'windows') | |
- name: Package as archive | |
shell: bash | |
run: | | |
cd target/${{ matrix.platform.target }}/release | |
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then | |
7z a ../../../${{ matrix.binary }}-${{ matrix.platform.os_name }}.zip ${{ matrix.binary }}.exe | |
else | |
chmod +x ${{ matrix.binary }} | |
tar czvf ../../../${{ matrix.binary }}-${{ matrix.platform.os_name }}.tar.gz ${{ matrix.binary }} | |
fi | |
cd - | |
- name: Publish build artifacts | |
uses: actions/upload-artifact@v4.4.0 | |
with: | |
name: ${{ matrix.binary }}-${{ matrix.platform.os_name }} | |
path: "${{ matrix.binary }}-${{ matrix.platform.os_name }}.*" | |
gh-release: | |
if: startsWith(github.ref, 'refs/tags/') | |
name: Release | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download artifacts | |
id: download_artifacts | |
uses: actions/download-artifact@v4.1.7 | |
with: | |
path: dist/ | |
- name: List files | |
run: ls -R ${{ steps.download_artifacts.outputs.download-path }} | |
- name: Generate checksums | |
id: checksums | |
run: | | |
cd ${{ steps.download_artifacts.outputs.download-path }} | |
for dir in $(ls -d */); do | |
cd $dir | |
for file in $(ls *.tar.gz *.zip); do | |
sha256sum $file > $file.sha256 | |
done | |
cd - | |
done | |
- name: Get the release tag | |
id: get_release_tag | |
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
- name: Create release body | |
id: body | |
shell: bash | |
run: | | |
touch body.txt | |
echo "Release for ${{ steps.get_release_tag.outputs.RELEASE_TAG }}" >> body.txt | |
echo "SHA256 Checksums:" >> body.txt | |
echo '```' >> body.txt | |
for file in ${{ steps.download_artifacts.outputs.download-path }}/**/*.sha256; do | |
echo "$(cat $file)" >> body.txt | |
done | |
echo '```' >> body.txt | |
echo "BODY<<EOF" >> $GITHUB_OUTPUT | |
cat body.txt >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Create or Update GitHub Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.get_release_tag.outputs.RELEASE_TAG }} | |
draft: false | |
prerelease: false | |
generate_release_notes: true | |
body: ${{ steps.body.outputs.BODY }} | |
files: | | |
${{ steps.download_artifacts.outputs.download-path }}/**/*.tar.gz | |
${{ steps.download_artifacts.outputs.download-path }}/**/*.zip | |
${{ steps.download_artifacts.outputs.download-path }}/**/*.sha256 |