Skip to content

temp chage for quick cicd test #11

temp chage for quick cicd test

temp chage for quick cicd test #11

Workflow file for this run

name: Create Release
on:
push:
branches:
- "**"
jobs:
build:
uses: iit-DLSLab/cicd_tools/.github/workflows/dls2_build_test.yml@main
with:
test-command: "ls"
output_workflow_artifact_name: build
secrets:
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
CICD_PAT: ${{ secrets.CICD_PAT }}
package-deb:
needs: build
runs-on: ubuntu-latest
container:
image: ghcr.io/iit-dlslab/dls2-dev:latest
credentials:
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.CICD_PAT }}
outputs:
dev_deb_artifact_name: ${{ steps.cpack.outputs.dev_deb_artifact_name }}
runtime_deb_artifact_name: ${{ steps.cpack.outputs.runtime_deb_artifact_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build
path: build
- name: Generate .deb packages
id: cpack
run: |
# Reconfigure cmake so cmake_install.cmake paths reflect the current
# runner workspace (compiled artifacts are already in build/ from the
# downloaded artifact; no recompilation happens here).
cmake -B build -S .
cd build
cpack -G DEB
cd ..
echo "Generated packages:"
ls -lh build/*.deb
DEV_DEB="$(ls build/dls-messages-dev.deb | head -1 | xargs basename)"
echo "dev_deb_artifact_name=${DEV_DEB}" >> "$GITHUB_OUTPUT"
- name: Upload dev .deb artifact
uses: actions/upload-artifact@v4
with:
name: dls-messages-dev-deb
path: build/dls-messages-dev.deb
if-no-files-found: error
release-on-push:
runs-on: ubuntu-latest
needs: package-deb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
set-safe-directory: true
- name: Normalize branch name
run: |
SAFE_BRANCH="${GITHUB_REF_NAME//\//-}"
SAFE_BRANCH="${SAFE_BRANCH//_/-}"
SAFE_BRANCH="$(echo "$SAFE_BRANCH" | tr '[:upper:]' '[:lower:]')"
echo "SAFE_BRANCH=$SAFE_BRANCH" >> "$GITHUB_ENV"
- name: Download dev .deb artifact
uses: actions/download-artifact@v4
with:
name: dls-messages-dev-deb
path: debs
- name: Download runtime .deb artifact
uses: actions/download-artifact@v4
with:
name: dls-messages-deb
path: debs
- name: Compute release tag
run: |
git fetch --tags --force
if [ "$GITHUB_REF_NAME" = "main" ]; then
LAST_VERSION="$(
git tag --list 'v[0-9]*.[0-9]*.[0-9]*' \
| sed 's/^v//' \
| grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \
| sort -V \
| tail -n 1
)"
if [ -z "$LAST_VERSION" ]; then
NEXT_VERSION="0.1.0"
else
MAJOR="$(echo "$LAST_VERSION" | cut -d. -f1)"
MINOR="$(echo "$LAST_VERSION" | cut -d. -f2)"
PATCH="$(echo "$LAST_VERSION" | cut -d. -f3)"
MINOR=$((MINOR + 1))
PATCH=0
NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}"
fi
RELEASE_TAG="v${NEXT_VERSION}"
else
PREFIX="temp-${SAFE_BRANCH}-v"
LAST_NUMBER="$(
git tag --list "${PREFIX}*" \
| sed "s/^${PREFIX}//" \
| grep -E '^[0-9]+$' \
| sort -n \
| tail -n 1
)"
if [ -z "$LAST_NUMBER" ]; then
NEXT_NUMBER=1
else
NEXT_NUMBER=$((LAST_NUMBER + 1))
fi
RELEASE_TAG="${PREFIX}${NEXT_NUMBER}"
fi
echo "RELEASE_TAG=$RELEASE_TAG" >> "$GITHUB_ENV"
echo "Computed release tag: $RELEASE_TAG"
- name: Create main GitHub release and upload assets
if: github.ref_name == 'main'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
name: ${{ env.RELEASE_TAG }}
target_commitish: ${{ github.sha }}
files: debs/*.deb
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create branch GitHub release and upload assets
if: github.ref_name != 'main'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
name: ${{ env.RELEASE_TAG }}
target_commitish: ${{ github.sha }}
files: debs/*.deb
make_latest: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}