Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI updates #29

Merged
merged 6 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 90 additions & 59 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
runs-on: ${{ matrix.os }}

env:
TAG: "0.0.0"
AMD64_LINUX_GCC: amd64-linux-gcc
AMD64_LINUX_CLANG: amd64-linux-clang
AMD64_WINDOWS_MINGW: amd64-windows-mingw
Expand All @@ -32,6 +33,20 @@ jobs:
ARTIFACT_RETENTION_DAYS: 5

steps:
- name: Get tag
uses: dawidd6/action-get-tag@v1
if: startsWith(github.ref, 'refs/tags/v')
id: tag
with:
strip_v: true

- name: Set TAG env var
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAG=${{ steps.tag.outputs.tag }}
echo "TAG: $TAG"
echo "TAG=$TAG" >> $GITHUB_ENV

- name: Checkout
uses: actions/checkout@v2

Expand Down Expand Up @@ -118,159 +133,175 @@ jobs:
# --- Upload build artifacts ---

- name: Prepare build artifacts for upload
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: ./scripts/ci-prepare-artifacts-for-upload.sh

- name: Upload (${{ env.AMD64_LINUX_GCC }}.zip)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.zip)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.zip
with:
name: zsv-${{ env.AMD64_LINUX_GCC }}.zip
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_LINUX_GCC }}.zip
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_LINUX_CLANG }}.zip)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.zip)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.zip
with:
name: zsv-${{ env.AMD64_LINUX_CLANG }}.zip
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_LINUX_CLANG }}.zip
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_LINUX_GCC }}.deb)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.deb)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.deb
with:
name: zsv-${{ env.AMD64_LINUX_GCC }}.deb
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_LINUX_GCC }}.deb
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_LINUX_CLANG }}.deb)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.deb)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.deb
with:
name: zsv-${{ env.AMD64_LINUX_CLANG }}.deb
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_LINUX_CLANG }}.deb
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_LINUX_GCC }}.rpm)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.rpm)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.rpm
with:
name: zsv-${{ env.AMD64_LINUX_GCC }}.rpm
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_LINUX_GCC }}.rpm
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_LINUX_CLANG }}.rpm)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.rpm)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.rpm
with:
name: zsv-${{ env.AMD64_LINUX_CLANG }}.rpm
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_LINUX_CLANG }}.rpm
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_WINDOWS_MINGW }}.zip)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.zip)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.zip
with:
name: zsv-${{ env.AMD64_WINDOWS_MINGW }}.zip
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_WINDOWS_MINGW }}.zip
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_WINDOWS_MINGW }}.nupkg)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.nupkg)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.nupkg
with:
name: zsv-${{ env.AMD64_WINDOWS_MINGW }}.nupkg
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_WINDOWS_MINGW }}.nupkg
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_MACOSX_CLANG }}.zip)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_MACOSX_CLANG }}.zip)
if: runner.os == 'macOS'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_MACOSX_CLANG }}.zip
with:
name: zsv-${{ env.AMD64_MACOSX_CLANG }}.zip
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_MACOSX_CLANG }}.zip
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_FREEBSD_GCC }}.zip)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_FREEBSD_GCC }}.zip)
if: runner.os == 'macOS'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_FREEBSD_GCC }}.zip
with:
name: zsv-${{ env.AMD64_FREEBSD_GCC }}.zip
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_FREEBSD_GCC }}.zip
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_LINUX_GCC }}.tar.gz)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.tar.gz)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.tar.gz
with:
name: zsv-${{ env.AMD64_LINUX_GCC }}.tar.gz
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_LINUX_GCC }}.tar.gz
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_LINUX_CLANG }}.tar.gz)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.tar.gz)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.tar.gz
with:
name: zsv-${{ env.AMD64_LINUX_CLANG }}.tar.gz
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_LINUX_CLANG }}.tar.gz
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_WINDOWS_MINGW }}.tar.gz)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.tar.gz)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.tar.gz
with:
name: zsv-${{ env.AMD64_WINDOWS_MINGW }}.tar.gz
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_WINDOWS_MINGW }}.tar.gz
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_MACOSX_CLANG }}.tar.gz)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_MACOSX_CLANG }}.tar.gz)
if: runner.os == 'macOS'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_MACOSX_CLANG }}.tar.gz
with:
name: zsv-${{ env.AMD64_MACOSX_CLANG }}.tar.gz
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_MACOSX_CLANG }}.tar.gz
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (${{ env.AMD64_FREEBSD_GCC }}.tar.gz)
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_FREEBSD_GCC }}.tar.gz)
if: runner.os == 'macOS'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_FREEBSD_GCC }}.tar.gz
with:
name: zsv-${{ env.AMD64_FREEBSD_GCC }}.tar.gz
path: ${{ env.ARTIFACT_DIR }}/zsv-${{ env.AMD64_FREEBSD_GCC }}.tar.gz
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

# --- Upload release artifacts ---

- name: Get release tag
uses: dawidd6/action-get-tag@v1
if: startsWith(github.ref, 'refs/tags/v')
id: tag
with:
strip_v: true

- name: Prepare release artifacts for upload with tag
if: startsWith(github.ref, 'refs/tags/v')
env:
TAG: ${{ steps.tag.outputs.tag }}
run: ./scripts/ci-prepare-artifacts-for-upload.sh

- name: Upload release artifacts
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
10 changes: 4 additions & 6 deletions scripts/ci-create-debian-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -e

echo "[INF] Running $0"

if [ "$PREFIX" = "" ] || [ "$ARTIFACT_DIR" = "" ]; then
if [ "$TAG" = "" ] || [ "$PREFIX" = "" ] || [ "$ARTIFACT_DIR" = "" ]; then
echo "[ERR] One or more environment variable(s) are not set!"
echo "[ERR] Set PREFIX and ARTIFACT_DIR before running $0 script."
echo "[ERR] Set TAG, PREFIX and ARTIFACT_DIR before running $0 script."
exit 1
fi

Expand All @@ -22,10 +22,7 @@ if [ ! -d "$ARTIFACT_DIR" ]; then
fi

ARCH="$(echo "$PREFIX" | cut -d '-' -f1)"
VERSION="$(date "+%-d.%-m.%y").$(date "+%s")"
if [ "$TAG" != "" ]; then
VERSION="$("$PREFIX/bin/zsv" version | cut -d ' ' -f3 | cut -c2-)"
fi
VERSION="$TAG"

DEBIAN_PKG="$PREFIX.deb"
DEBIAN_DIR="$PREFIX/DEBIAN"
Expand All @@ -35,6 +32,7 @@ DEBIAN_PREINST_SCRIPT="$DEBIAN_DIR/preinst"
echo "[INF] Creating debian package [$DEBIAN_PKG]"

echo "[INF] PWD: $PWD"
echo "[INF] TAG: $TAG"
echo "[INF] PREFIX: $PREFIX"
echo "[INF] ARTIFACT_DIR: $ARTIFACT_DIR"
echo "[INF] ARCH: $ARCH"
Expand Down
12 changes: 5 additions & 7 deletions scripts/ci-create-nuget-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -e

echo "[INF] Running $0"

if [ "$PREFIX" = "" ] || [ "$ARTIFACT_DIR" = "" ]; then
if [ "$TAG" = "" ] || [ "$PREFIX" = "" ] || [ "$ARTIFACT_DIR" = "" ]; then
echo "[ERR] One or more environment variable(s) are not set!"
echo "[ERR] Set PREFIX and ARTIFACT_DIR before running $0 script."
echo "[ERR] Set TAG, PREFIX and ARTIFACT_DIR before running $0 script."
exit 1
fi

Expand All @@ -22,20 +22,18 @@ if [ ! -d "$ARTIFACT_DIR" ]; then
fi

ARCH="$(echo "$PREFIX" | cut -d '-' -f1)"
VERSION="$(date "+%-d.%-m.%y").$(date "+%s")"
if [ "$TAG" != "" ]; then
VERSION="$("$PREFIX/bin/zsv" version | cut -d ' ' -f3 | cut -c2-)"
fi
VERSION="$TAG"

NUGET_PKG="zsv.$VERSION.nupkg"
NUGET_PKG_PATH="$ARTIFACT_DIR/zsv-$PREFIX.nupkg"
NUGET_PKG_PATH="$ARTIFACT_DIR/$PREFIX.nupkg"
NUGET_PKG_FEED="$PWD/nuget-feed"
NUGET_SPEC='zsv.nuspec'
NUGET_SPEC_PATH="$PREFIX/$NUGET_SPEC"

echo "[INF] Creating nuget package [$NUGET_PKG]"

echo "[INF] PWD: $PWD"
echo "[INF] TAG: $TAG"
echo "[INF] PREFIX: $PREFIX"
echo "[INF] ARTIFACT_DIR: $ARTIFACT_DIR"
echo "[INF] ARCH: $ARCH"
Expand Down
10 changes: 4 additions & 6 deletions scripts/ci-create-rpm-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -e

echo "[INF] Running $0"

if [ "$PREFIX" = "" ] || [ "$ARTIFACT_DIR" = "" ]; then
if [ "$TAG" = "" ] || [ "$PREFIX" = "" ] || [ "$ARTIFACT_DIR" = "" ]; then
echo "[ERR] One or more environment variable(s) are not set!"
echo "[ERR] Set PREFIX and ARTIFACT_DIR before running $0 script."
echo "[ERR] Set TAG, PREFIX and ARTIFACT_DIR before running $0 script."
exit 1
fi

Expand All @@ -22,10 +22,7 @@ if [ ! -d "$ARTIFACT_DIR" ]; then
fi

ARCH="$(echo "$PREFIX" | cut -d '-' -f1)"
VERSION="$(date "+%-d.%-m.%y").$(date "+%s")"
if [ "$TAG" != "" ]; then
VERSION="$("$PREFIX/bin/zsv" version | cut -d ' ' -f3 | cut -c2-)"
fi
VERSION="$(echo "$TAG" | cut -c1- | cut -d '-' -f1)"

RPM_DIR="$HOME/rpmbuild"
RPM_PKG="$PREFIX.rpm"
Expand All @@ -36,6 +33,7 @@ RPM_SPEC_PATH="$RPM_DIR/SPECS/$RPM_SPEC"
echo "[INF] Creating rpm package [$RPM_PKG]"

echo "[INF] PWD: $PWD"
echo "[INF] TAG: $TAG"
echo "[INF] PREFIX: $PREFIX"
echo "[INF] ARTIFACT_DIR: $ARTIFACT_DIR"
echo "[INF] ARCH: $ARCH"
Expand Down
12 changes: 4 additions & 8 deletions scripts/ci-prepare-artifacts-for-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -e

echo "[INF] Running $0"

if [ "$ARTIFACT_DIR" = "" ]; then
if [ "$TAG" = "" ] || [ "$ARTIFACT_DIR" = "" ]; then
echo "[ERR] One or more environment variable(s) are not set!"
echo "[ERR] Set ARTIFACT_DIR before running $0 script."
echo "[ERR] Set TAG and ARTIFACT_DIR before running $0 script."
exit 1
fi

Expand All @@ -15,11 +15,7 @@ if [ ! -d "$ARTIFACT_DIR" ]; then
exit 1
fi

ARTIFACT_PREFIX='zsv'
if [ "$TAG" != "" ]; then
VERSION="$("$PREFIX/bin/zsv" version | cut -d ' ' -f3 | cut -c2-)"
ARTIFACT_PREFIX="zsv-$VERSION"
fi
ARTIFACT_PREFIX="zsv-$TAG"

echo "[INF] Preparing build artifacts for upload"

Expand All @@ -36,7 +32,7 @@ prepare() {
[ "$FILE_PREFIX" = "$ARTIFACT_PREFIX" ] && continue
UPDATED_ARTIFACT_NAME="$ARTIFACT_PREFIX-$ARTIFACT_NAME"
echo "[INF] [$ARTIFACT_NAME] => [$UPDATED_ARTIFACT_NAME]"
cp "$ARTIFACT_NAME" "$UPDATED_ARTIFACT_NAME"
mv -f "$ARTIFACT_NAME" "$UPDATED_ARTIFACT_NAME"
done
}

Expand Down