Awiteb
8a80e58e54
All checks were successful
Write changelog / write-changelog (push) Successful in 4s
Rust CI / Rust CI (push) Successful in 7m0s
CD / build-assets (aarch64-unknown-linux-gnu) (push) Successful in 7m7s
CD / build-assets (aarch64-unknown-linux-musl) (push) Successful in 7m8s
CD / build-assets (x86_64-unknown-linux-gnu) (push) Successful in 4m11s
CD / build-assets (x86_64-unknown-linux-musl) (push) Successful in 4m14s
CD / release (push) Successful in 12s
Signed-off-by: Awiteb <a@4rs.nl>
106 lines
4 KiB
YAML
106 lines
4 KiB
YAML
name: CD
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- v[0-9]+.[0-9]+.[0-9]+
|
|
- v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+
|
|
|
|
jobs:
|
|
build-assets:
|
|
runs-on: debian
|
|
strategy:
|
|
matrix:
|
|
target:
|
|
- x86_64-unknown-linux-gnu
|
|
- x86_64-unknown-linux-musl
|
|
- aarch64-unknown-linux-gnu
|
|
- aarch64-unknown-linux-musl
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: master
|
|
fetch-depth: 1
|
|
- uses: https://codeberg.org/awiteb/rust-action@v1.74
|
|
- name: Install musl-tools
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y musl-tools
|
|
if: ${{ contains(matrix.target, 'musl') }}
|
|
- name: Install gcc-aarch64-linux-gnu linker
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y gcc-aarch64-linux-gnu
|
|
if: ${{ contains(matrix.target, 'aarch64') }}
|
|
- name: Preparing the environment
|
|
run: |
|
|
BIN_NAME="$(echo $GITHUB_REPOSITORY | cut -d '/' -f 2)"
|
|
echo "BIN_NAME=$BIN_NAME" >> $GITHUB_ENV
|
|
mkdir -p release-dir
|
|
mkdir -p .cargo
|
|
echo 'target.aarch64-unknown-linux-gnu.linker = "aarch64-linux-gnu-gcc"' > .cargo/config.toml
|
|
echo 'target.aarch64-unknown-linux-musl.linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml
|
|
|
|
- name: Install the target
|
|
run: rustup target install ${{ matrix.target }}
|
|
|
|
- name: Build the asset
|
|
run: |
|
|
TARGET=$(echo ${{ matrix.target }} | sed -e 's/-unknown//g' | sed -e 's/-pc//g')
|
|
APP_NAME="$BIN_NAME-$GITHUB_REF_NAME-$TARGET"
|
|
cargo clean
|
|
cargo build --release --target ${{ matrix.target }}
|
|
cp target/${{ matrix.target }}/release/$BIN_NAME release-dir/$APP_NAME
|
|
cd release-dir
|
|
test -f $APP_NAME && sha256sum $APP_NAME > $APP_NAME.sha256
|
|
|
|
# Upload the artifact, so it can be used in the release step
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ env.GITHUB_SHA }}-${{ env.GITHUB_RUN_NUMBER }}
|
|
path: ${{ env.GITHUB_WORKSPACE }}/release-dir
|
|
|
|
release:
|
|
needs: build-assets
|
|
runs-on: debian
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: master
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: ${{ env.GITHUB_SHA }}-${{ env.GITHUB_RUN_NUMBER }}
|
|
path: ${{ env.GITHUB_WORKSPACE }}/release-dir
|
|
- name: Install git-cliff
|
|
run: |
|
|
version="2.4.0"
|
|
wget "https://github.com/orhun/git-cliff/releases/download/v$version/git-cliff-$version-x86_64-unknown-linux-gnu.tar.gz"
|
|
tar -xvzf git-cliff-*.tar.gz
|
|
mv "git-cliff-$version/git-cliff" /usr/local/bin
|
|
rm -fr git-cliff-*
|
|
- name: Write changelog
|
|
run: |
|
|
git config user.name forgejo-actions
|
|
git config user.email forgejo-actions@noreply.localhost
|
|
echo 'TAG_CHANGELOG=$(if [[ $(git tag --sort=committerdate | tail -n 1) == *"-rc"* ]]; then git-cliff --strip all $(git tag --sort=committerdate | tail -n 2 | sed ":a; N; $!ba; s/\n/../g") | sed "s/## unreleased.*$//g"; else git-cliff -l --strip all | sed "s/^## \[.*$//g";fi)' | sed "s/\"/'/g" >> $GITHUB_ENV
|
|
if [[ $(git tag --sort=creatordate | tail -n 1) != *'-rc'* ]]; then
|
|
echo "The latest tag is not a release candidate, updating changelog for $GITHUB_REF_NAME"
|
|
git-cliff > CHANGELOG.md
|
|
git add CHANGELOG.md
|
|
git commit -m "Update changelog for $GITHUB_REF_NAME"
|
|
git push
|
|
echo "Changelog updated"
|
|
else
|
|
echo "The latest tag is a release candidate, not updating changelog"
|
|
fi
|
|
- name: Create Release
|
|
uses: actions/forgejo-release@v1
|
|
with:
|
|
direction: upload
|
|
url: https://git.4rs.nl
|
|
token: ${{ env.GITHUB_TOKEN }}
|
|
release-dir: release-dir
|
|
release-notes: ${{ env.TAG_CHANGELOG }}
|
|
prerelease: ${{ contains(env.GITHUB_REF_NAME, '-rc') }}
|