Skip to content

Commit 584ee64

Browse files
authored
Follow Security Guide to update release.yml (#71)
<!--- Title --> Follow Security Guide to update release.yml Description ----------- <!--- Describe your changes in detail. --> 1. Update release.yml with latest version from other library. 2. Follow [Security Guide](https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#understanding-the-risk-of-script-injections) to update release.yml. Test Steps ----------- <!-- Describe the steps to reproduce. --> Execute release flow in local branch, see result on https://github.com/ActoryOu/coreMQTT/actions/runs/11662840570. Checklist: ---------- <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [NA] I have tested my changes. No regression in existing tests. - [NA] I have modified and/or added unit-tests to cover the code changes in this Pull Request. Related Issue ----------- <!-- If any, please provide issue ID. --> By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 0085e3d commit 584ee64

File tree

2 files changed

+57
-22
lines changed

2 files changed

+57
-22
lines changed

.github/.cSpellWords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ CPSECURE
2727
CPSM
2828
CREATELFNS
2929
CSDK
30+
CTOUTF
3031
Chrs
3132
Cmock
3233
Comd

.github/workflows/release.yml

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ on:
44
workflow_dispatch:
55
inputs:
66
commit_id:
7-
description: "Commit ID to tag and create a release for"
7+
description: 'Commit ID to tag and create a release for'
88
required: true
99
version_number:
10-
description: "Release Version Number (Eg, v1.0.0)"
10+
description: 'Release Version Number (Eg, v1.0.0)'
1111
required: true
1212

1313
jobs:
@@ -16,35 +16,47 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout code
19-
uses: actions/checkout@v2
19+
uses: actions/checkout@v4
2020
with:
2121
ref: ${{ github.event.inputs.commit_id }}
2222
- name: Configure git identity
23+
env:
24+
ACTOR: ${{ github.actor }}
2325
run: |
24-
git config --global user.name ${{ github.actor }}
25-
git config --global user.email ${{ github.actor }}@users.noreply.github.com
26+
git config --global user.name "$ACTOR"
27+
git config --global user.email "$ACTOR"@users.noreply.github.com
2628
- name: create a new branch that references commit id
27-
run: git checkout -b ${{ github.event.inputs.version_number }} ${{ github.event.inputs.commit_id }}
29+
env:
30+
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
31+
COMMIT_ID: ${{ github.event.inputs.commit_id }}
32+
run: git checkout -b "$VERSION_NUMBER" "$COMMIT_ID"
2833
- name: Generate SBOM
2934
uses: FreeRTOS/CI-CD-Github-Actions/sbom-generator@main
3035
with:
3136
repo_path: ./
3237
source_path: ./source
3338
- name: commit SBOM file
39+
env:
40+
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
3441
run: |
3542
git add .
3643
git commit -m 'Update SBOM'
37-
git push -u origin ${{ github.event.inputs.version_number }}
44+
git push -u origin "$VERSION_NUMBER"
3845
- name: Tag Commit and Push to remote
46+
env:
47+
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
3948
run: |
40-
git tag ${{ github.event.inputs.version_number }} -a -m "FreeRTOS-Plus-FAT Library ${{ github.event.inputs.version_number }}"
49+
git tag "$VERSION_NUMBER" -a -m "FreeRTOS-Plus-FAT Library $VERSION_NUMBER"
4150
git push origin --tags
4251
- name: Verify tag on remote
52+
env:
53+
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
54+
COMMIT_ID: ${{ github.event.inputs.commit_id }}
4355
run: |
44-
git tag -d ${{ github.event.inputs.version_number }}
56+
git tag -d "$VERSION_NUMBER"
4557
git remote update
46-
git checkout tags/${{ github.event.inputs.version_number }}
47-
git diff ${{ github.event.inputs.commit_id }} tags/${{ github.event.inputs.version_number }}
58+
git checkout tags/"$VERSION_NUMBER"
59+
git diff "$COMMIT_ID" tags/"$VERSION_NUMBER"
4860
create-zip:
4961
needs: tag-commit
5062
name: Create ZIP and verify package for release asset.
@@ -53,46 +65,54 @@ jobs:
5365
- name: Install ZIP tools
5466
run: sudo apt-get install zip unzip
5567
- name: Checkout code
56-
uses: actions/checkout@v2
68+
uses: actions/checkout@v4
5769
with:
58-
ref: ${{ github.event.inputs.commit_id }}
70+
ref: ${{ github.event.inputs.version_number }}
5971
path: FreeRTOS-Plus-FAT
6072
submodules: recursive
6173
- name: Checkout disabled submodules
6274
run: |
6375
cd FreeRTOS-Plus-FAT
6476
git submodule update --init --checkout --recursive
6577
- name: Create ZIP
78+
env:
79+
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
6680
run: |
67-
zip -r FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}.zip FreeRTOS-Plus-FAT -x "*.git*"
81+
zip -r FreeRTOS-Plus-FAT-"$VERSION_NUMBER".zip FreeRTOS-Plus-FAT -x "*.git*"
6882
ls ./
6983
- name: Validate created ZIP
84+
env:
85+
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
7086
run: |
7187
mkdir zip-check
72-
mv FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}.zip zip-check
88+
mv FreeRTOS-Plus-FAT-"$VERSION_NUMBER".zip zip-check
7389
cd zip-check
74-
unzip FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}.zip -d FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}
75-
ls FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}
76-
diff -r -x "*.git*" FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}/FreeRTOS-Plus-FAT/ ../FreeRTOS-Plus-FAT/
90+
unzip FreeRTOS-Plus-FAT-"$VERSION_NUMBER".zip -d FreeRTOS-Plus-FAT-"$VERSION_NUMBER"
91+
ls FreeRTOS-Plus-FAT-"$VERSION_NUMBER"
92+
diff -r -x "*.git*" FreeRTOS-Plus-FAT-"$VERSION_NUMBER"/FreeRTOS-Plus-FAT/ ../FreeRTOS-Plus-FAT/
7793
cd ../
7894
- name: Build
95+
env:
96+
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
7997
run: |
80-
cd zip-check/FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}/FreeRTOS-Plus-FAT
98+
cd zip-check/FreeRTOS-Plus-FAT-"$VERSION_NUMBER"/FreeRTOS-Plus-FAT
8199
sudo apt-get install -y lcov
82100
sudo apt-get install unifdef
83101
cmake -S test/unit-test -B test/unit-test/build/
84102
make -C test/unit-test/build/ all
85103
- name: Test
104+
env:
105+
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
86106
run: |
87-
cd zip-check/FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}/FreeRTOS-Plus-FAT
107+
cd zip-check/FreeRTOS-Plus-FAT-"$VERSION_NUMBER"/FreeRTOS-Plus-FAT
88108
pushd test/unit-test/build/
89109
ctest -E system --output-on-failure
90110
popd
91111
make -C test/unit-test/build/ coverage
92112
lcov --list --rc lcov_branch_coverage=1 test/unit-test/build/coverage.info
93113
cd ..
94114
- name: Create artifact of ZIP
95-
uses: actions/upload-artifact@v2
115+
uses: actions/upload-artifact@v4
96116
with:
97117
name: FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}.zip
98118
path: zip-check/FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}.zip
@@ -125,7 +145,7 @@ jobs:
125145
draft: false
126146
prerelease: false
127147
- name: Download ZIP artifact
128-
uses: actions/download-artifact@v4.1.7
148+
uses: actions/download-artifact@v4
129149
with:
130150
name: FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}.zip
131151
- name: Upload Release Asset
@@ -138,3 +158,17 @@ jobs:
138158
asset_path: ./FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}.zip
139159
asset_name: FreeRTOS-Plus-FAT-${{ github.event.inputs.version_number }}.zip
140160
asset_content_type: application/zip
161+
cleanup:
162+
needs:
163+
- create-release
164+
name: Cleanup
165+
runs-on: ubuntu-latest
166+
steps:
167+
- name: Checkout code
168+
uses: actions/checkout@v4
169+
- name: Delete branch created for Tag by SBOM generator
170+
env:
171+
VERSION_NUMBER: ${{ github.event.inputs.version_number }}
172+
run: |
173+
# Delete the branch created for Tag by SBOM generator
174+
git push -u origin --delete refs/heads/"$VERSION_NUMBER"

0 commit comments

Comments
 (0)