From cf8da222da3319b7e3108edfe1be380d3788a18e Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Fri, 22 Nov 2024 07:32:39 +0000 Subject: [PATCH] Follow Security Guide to update YAML files. --- .github/workflows/release.yml | 50 ++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2e89994..55127a3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,31 +20,43 @@ jobs: with: ref: ${{ github.event.inputs.commit_id }} - name: Configure git identity + env: + ACTOR: ${{ github.actor }} run: | - git config --global user.name ${{ github.actor }} - git config --global user.email ${{ github.actor }}@users.noreply.github.com + git config --global user.name "$ACTOR" + git config --global user.email "$ACTOR"@users.noreply.github.com - name: create a new branch that references commit id - run: git checkout -b ${{ github.event.inputs.version_number }} ${{ github.event.inputs.commit_id }} + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} + COMMIT_ID: ${{ github.event.inputs.commit_id }} + run: git checkout -b "$VERSION_NUMBER" "$COMMIT_ID" - name: Generate SBOM uses: FreeRTOS/CI-CD-Github-Actions/sbom-generator@main with: repo_path: ./ source_path: ./source - name: commit SBOM file + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} run: | git add . git commit -m 'Update SBOM' - git push -u origin ${{ github.event.inputs.version_number }} + git push -u origin "$VERSION_NUMBER" - name: Tag Commit and Push to remote + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} run: | - git tag ${{ github.event.inputs.version_number }} -a -m "backoffAlgorithm Library ${{ github.event.inputs.version_number }}" + git tag "$VERSION_NUMBER" -a -m "backoffAlgorithm Library $VERSION_NUMBER" git push origin --tags - name: Verify tag on remote + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} + COMMIT_ID: ${{ github.event.inputs.commit_id }} run: | - git tag -d ${{ github.event.inputs.version_number }} + git tag -d "$VERSION_NUMBER" git remote update - git checkout tags/${{ github.event.inputs.version_number }} - git diff ${{ github.event.inputs.commit_id }} tags/${{ github.event.inputs.version_number }} + git checkout tags/"$VERSION_NUMBER" + git diff "$COMMIT_ID" tags/"$VERSION_NUMBER" create-zip: needs: tag-commit name: Create ZIP and verify package for release asset. @@ -63,21 +75,27 @@ jobs: cd backoffAlgorithm git submodule update --init --checkout --recursive - name: Create ZIP + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} run: | - zip -r backoffAlgorithm-${{ github.event.inputs.version_number }}.zip backoffAlgorithm -x "*.git*" + zip -r backoffAlgorithm-"$VERSION_NUMBER".zip backoffAlgorithm -x "*.git*" ls ./ - name: Validate created ZIP + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} run: | mkdir zip-check - mv backoffAlgorithm-${{ github.event.inputs.version_number }}.zip zip-check + mv backoffAlgorithm-"$VERSION_NUMBER".zip zip-check cd zip-check - unzip backoffAlgorithm-${{ github.event.inputs.version_number }}.zip -d backoffAlgorithm-${{ github.event.inputs.version_number }} - ls backoffAlgorithm-${{ github.event.inputs.version_number }} - diff -r -x "*.git*" backoffAlgorithm-${{ github.event.inputs.version_number }}/backoffAlgorithm/ ../backoffAlgorithm/ + unzip backoffAlgorithm-"$VERSION_NUMBER".zip -d backoffAlgorithm-"$VERSION_NUMBER" + ls backoffAlgorithm-"$VERSION_NUMBER" + diff -r -x "*.git*" backoffAlgorithm-"$VERSION_NUMBER"/backoffAlgorithm/ ../backoffAlgorithm/ cd ../ - name: Build + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} run: | - cd zip-check/backoffAlgorithm-${{ github.event.inputs.version_number }}/backoffAlgorithm + cd zip-check/backoffAlgorithm-"$VERSION_NUMBER"/backoffAlgorithm sudo apt-get install -y lcov cmake -S test -B build/ \ -G "Unix Makefiles" \ @@ -86,8 +104,10 @@ jobs: -DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror' make -C build/ all - name: Test + env: + VERSION_NUMBER: ${{ github.event.inputs.version_number }} run: | - cd zip-check/backoffAlgorithm-${{ github.event.inputs.version_number }}/backoffAlgorithm/build/ + cd zip-check/backoffAlgorithm-"$VERSION_NUMBER"/backoffAlgorithm/build/ ctest -E system --output-on-failure cd .. - name: Create artifact of ZIP