Skip to content

Commit

Permalink
ci: Add release flow
Browse files Browse the repository at this point in the history
  • Loading branch information
colluca committed Feb 20, 2024
1 parent 46ac2de commit 24eaeda
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/scripts/build_spike_dasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

autoconf
mkdir build; cd build
../configure
make
22 changes: 22 additions & 0 deletions .github/scripts/gen_dockerfile.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions .github/scripts/package.sh
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ autom4te.cache/
*.o
*.d
.gdb_history
Dockerfile

0 comments on commit 24eaeda

Please sign in to comment.