From 24eaedaa148e544820b100d1a69b85222ab0eb7c Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Tue, 20 Feb 2024 12:03:28 +0100 Subject: [PATCH] ci: Add release flow --- .github/scripts/build_spike_dasm.sh | 6 ++++ .github/scripts/gen_dockerfile.sh | 22 ++++++++++++ .github/scripts/package.sh | 11 ++++++ .github/workflows/release.yaml | 53 +++++++++++++++++++++++++++++ .gitignore | 1 + 5 files changed, 93 insertions(+) create mode 100755 .github/scripts/build_spike_dasm.sh create mode 100755 .github/scripts/gen_dockerfile.sh create mode 100755 .github/scripts/package.sh create mode 100644 .github/workflows/release.yaml diff --git a/.github/scripts/build_spike_dasm.sh b/.github/scripts/build_spike_dasm.sh new file mode 100755 index 0000000000..95304a6e90 --- /dev/null +++ b/.github/scripts/build_spike_dasm.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +autoconf +mkdir build; cd build +../configure +make diff --git a/.github/scripts/gen_dockerfile.sh b/.github/scripts/gen_dockerfile.sh new file mode 100755 index 0000000000..0638e688cf --- /dev/null +++ b/.github/scripts/gen_dockerfile.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +export filename="Dockerfile" +rm -f $filename +touch $filename + +echo "FROM $full_tgtname" >> $filename +echo >> $filename +if [ $(echo $full_tgtname | cut -d ':' -f 1) = "ubuntu" ]; then + echo 'RUN apt update && apt -y install build-essential curl device-tree-compiler' >> $filename +fi +if [ $(echo $full_tgtname | cut -d ':' -f 1) = "almalinux" ]; then + if [ $(echo $full_tgtname | cut -d ':' -f 2 | cut -d '.' -f 1) = '8' ]; then + echo 'RUN rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux' >> $filename + fi + echo 'RUN dnf -y update && dnf -y group install "Development Tools"' >> $filename + echo 'RUN dnf config-manager --add-repo /etc/yum.repos.d/almalinux-powertools.repo' >> $filename + echo 'RUN dnf config-manager --set-enabled powertools' >> $filename + echo 'RUN dnf -y install dtc' >> $filename +fi +echo >> $filename +echo 'WORKDIR /source' >> $filename diff --git a/.github/scripts/package.sh b/.github/scripts/package.sh new file mode 100755 index 0000000000..6dd753117d --- /dev/null +++ b/.github/scripts/package.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +if [[ "$GITHUB_REF" =~ ^refs/tags/snitch-v.*$ ]]; then + readonly pkgver="$(echo $GITHUB_REF | sed -n 's/^refs\/tags\/snitch-v//p')" +else + echo "Github reference does not match Snitch version tag pattern" + exit 1 +fi + +tar -czf "snitch-spike-dasm-$pkgver-x86_64-linux-gnu-$1.tar.gz" \ + --owner=0 --group=0 build/spike-dasm \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000000..93ea36c7c2 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,53 @@ +name: release + +on: + release: + types: [created] + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + rust: + - stable + os: + - ubuntu:18.04 + - almalinux:8.7 + steps: + - uses: actions/checkout@v3 + - name: OS Build + run: | + export full_tgtname=${{ matrix.os }} + export tgtname=$(echo ${{ matrix.os }} | tr -d ':') + .github/scripts/gen_dockerfile.sh + docker build ./ -t $tgtname + shell: bash + - name: Create package + run: | + export tgtname=$(echo ${{ matrix.os }} | tr -d ':') + docker run \ + -t --rm \ + -v "$GITHUB_WORKSPACE:/source" \ + $tgtname \ + .github/scripts/build_spike_dasm.sh; + .github/scripts/package.sh $tgtname; + shell: bash + - name: Get Artifact Name + run: | + ARTIFACT_PATHNAME=$(ls ./snitch-spike-dasm-*.tar.gz | head -n 1) + ARTIFACT_NAME=$(basename $ARTIFACT_PATHNAME) + echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV + echo "ARTIFACT_PATHNAME=${ARTIFACT_PATHNAME}" >> $GITHUB_ENV + shell: bash + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ${{ env.ARTIFACT_PATHNAME }} + asset_name: ${{ env.ARTIFACT_NAME }} + asset_content_type: application/tar.gz diff --git a/.gitignore b/.gitignore index 14326e9c6b..07cc4ec5d9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ autom4te.cache/ *.o *.d .gdb_history +Dockerfile