Skip to content

Commit 10dbc81

Browse files
committed
Add workflow to automate FST regeneration and release creation
Signed-off-by: Keshav Priyadarshi <[email protected]>
1 parent 24f2c56 commit 10dbc81

File tree

1 file changed

+70
-2
lines changed

1 file changed

+70
-2
lines changed

.github/workflows/sync-purls.yml

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Collect latest PURLs from FederatedCode
1+
name: Collect latest PURLs from FederatedCode and create release with latest FST
22

33
on:
44
workflow_dispatch:
@@ -11,7 +11,7 @@ permissions:
1111
jobs:
1212
collect-purls:
1313
strategy:
14-
max-parallel: 4
14+
max-parallel: 1
1515
matrix:
1616
include:
1717
- ecosystem: apk
@@ -31,3 +31,71 @@ jobs:
3131
with:
3232
ecosystem: ${{ matrix.ecosystem }}
3333
path: "fst_builder/data/${{ matrix.ecosystem }}.txt"
34+
35+
regen-fst-and-release:
36+
name: Regenerate FST and create release using new FST
37+
needs: collect-purls
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout source
41+
uses: actions/checkout@v4
42+
with:
43+
token: ${{ secrets.GH_TAG_RELEASE_TOKEN }}
44+
45+
- name: Install Rust
46+
uses: dtolnay/rust-toolchain@stable
47+
48+
- name: Install cargo-edit
49+
run: cargo install cargo-edit
50+
51+
- name: Regenerate FST
52+
id: regen_fst
53+
run: |-
54+
git pull
55+
make build-fst
56+
git diff --name-only | grep -q 'purls.fst' && echo "changed=true" >> $GITHUB_OUTPUT \
57+
|| echo "changed=false" >> $GITHUB_OUTPUT
58+
59+
# Commit latest FST
60+
git config user.name "AboutCode Automation"
61+
git config user.email "[email protected]"
62+
git add purls.fst
63+
git commit -m "$(echo -e "Regenerate FST using latest PURLs\n\nSigned-off-by: AboutCode Automation <[email protected]>")" || exit 0
64+
git push
65+
66+
- name: Bump minor version
67+
id: bump
68+
if: steps.regen_fst.outputs.changed == 'true'
69+
run: |-
70+
output=$(cargo set-version --bump minor 2>&1)
71+
new_version=$(echo "$output" | awk '{print $NF}')
72+
73+
echo "new_version=$new_version" >> $GITHUB_OUTPUT
74+
75+
- name: Add Changelog
76+
if: steps.regen_fst.outputs.changed == 'true'
77+
run: |-
78+
# Add Changelog
79+
today=$(date +%Y-%m-%d)
80+
awk -v ver="${{ steps.bump.outputs.new_version }}" -v date="$today" '
81+
NR==1{
82+
print "# Changelog\n\n## v" ver " (" date ")\n\n - Update FST with latest PURLs"
83+
next
84+
}1' CHANGELOG.md > .tmp.CHANGELOG.md && mv .tmp.CHANGELOG.md CHANGELOG.md
85+
86+
- name: Commit Changelog and Lock files
87+
if: steps.regen_fst.outputs.changed == 'true'
88+
run: |-
89+
# Commit Changelog and Lock files
90+
git config user.name "AboutCode Automation"
91+
git config user.email "[email protected]"
92+
git add -A
93+
git commit -m "$(echo -e "Bump version for v${{ steps.bump.outputs.new_version }} release\n\nSigned-off-by: AboutCode Automation <[email protected]>")" || exit 0
94+
git push
95+
96+
- name: Push tag
97+
if: steps.regen_fst.outputs.changed == 'true'
98+
run: |-
99+
# Push tag
100+
git tag -a "v${{ steps.bump.outputs.new_version }}" -m "Release v${{ steps.bump.outputs.new_version }}"
101+
git push origin "v${{ steps.bump.outputs.new_version }}"

0 commit comments

Comments
 (0)