Skip to content

Commit

Permalink
Update release.yml as per security guidleine (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
kar-rahul-aws authored Nov 6, 2024
1 parent 73e76fe commit 55b42ff
Showing 1 changed file with 36 additions and 16 deletions.
52 changes: 36 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,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 "coreSNTP Library ${{ github.event.inputs.version_number }}"
git tag "$VERSION_NUMBER" -a -m "coreSNTP 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:
if: ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
needs: tag-commit
Expand All @@ -96,22 +108,28 @@ jobs:
run: |
cd coreSNTP
git submodule update --init --checkout --recursive
- name: Create ZIP
- name:
env:
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
run: |
zip -r coreSNTP-${{ github.event.inputs.version_number }}.zip coreSNTP -x "*.git*"
zip -r coreSNTP-"$VERSION_NUMBER".zip coreSNTP -x "*.git*"
ls ./
- name: Validate created ZIP
env:
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
run: |
mkdir zip-check
mv coreSNTP-${{ github.event.inputs.version_number }}.zip zip-check
mv coreSNTP-"$VERSION_NUMBER".zip zip-check
cd zip-check
unzip coreSNTP-${{ github.event.inputs.version_number }}.zip -d coreSNTP-${{ github.event.inputs.version_number }}
ls coreSNTP-${{ github.event.inputs.version_number }}
diff -r -x "*.git*" coreSNTP-${{ github.event.inputs.version_number }}/coreSNTP/ ../coreSNTP/
unzip coreSNTP-"$VERSION_NUMBER".zip -d coreSNTP-"$VERSION_NUMBER"
ls coreSNTP-"$VERSION_NUMBER"
diff -r -x "*.git*" coreSNTP-"$VERSION_NUMBER"/coreSNTP/ ../coreSNTP/
cd ../
- name: Build
env:
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
run: |
cd zip-check/coreSNTP-${{ github.event.inputs.version_number }}/coreSNTP
cd zip-check/coreSNTP-"$VERSION_NUMBER"/coreSNTP
sudo apt-get install -y lcov
cmake -S test -B build/ \
-G "Unix Makefiles" \
Expand All @@ -120,8 +138,10 @@ jobs:
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -DNDEBUG'
make -C build/ all
- name: Test
env:
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
run: |
cd zip-check/coreSNTP-${{ github.event.inputs.version_number }}/coreSNTP/build/
cd zip-check/coreSNTP-"$VERSION_NUMBER"/coreSNTP/build/
ctest -E system --output-on-failure
cd ..
- name: Create artifact of ZIP
Expand Down

0 comments on commit 55b42ff

Please sign in to comment.