using source tree for debian package #22
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Create Release | |
| on: | |
| push: | |
| branches: | |
| - "**" | |
| jobs: | |
| build_test_package: | |
| 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: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/iit-dlslab/dls2-dev:latest | |
| credentials: | |
| username: ${{ secrets.GHCR_USERNAME || github.actor }} | |
| password: ${{ secrets.CICD_PAT || github.token }} | |
| needs: build_test_package | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| set-safe-directory: true | |
| submodules: recursive | |
| token: ${{ secrets.CICD_PAT || github.token }} | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build | |
| path: . | |
| - name: Configure git credentials for cmake FetchContent | |
| shell: bash | |
| env: | |
| CICD_PAT: ${{ secrets.CICD_PAT }} | |
| run: | | |
| set -euo pipefail | |
| TOKEN="${CICD_PAT:-$GITHUB_TOKEN}" | |
| git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/" | |
| - name: Create debian package | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| 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 }} |