Skip to content

Commit 516e69a

Browse files
committed
Automate FST regeneration and release creation
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 5cf5883 commit 516e69a

4 files changed

Lines changed: 116 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
jobs:
1010
publish:
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
1214

1315
steps:
1416
- name: Create a GitHub release

.github/workflows/sync-purls.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Collect latest PURLs from FederatedCode and create release with latest FST
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
collect-purls:
13+
strategy:
14+
max-parallel: 1
15+
matrix:
16+
include:
17+
- ecosystem: apk
18+
- ecosystem: cargo
19+
- ecosystem: composer
20+
- ecosystem: conan
21+
- ecosystem: cpan
22+
- ecosystem: cran
23+
- ecosystem: debain
24+
- ecosystem: maven
25+
- ecosystem: npm
26+
- ecosystem: nuget
27+
- ecosystem: pypi
28+
- ecosystem: swift
29+
30+
uses: aboutcode-org/purl-validator.rs/.github/workflows/collect-purls_template.yml
31+
with:
32+
ecosystem: ${{ matrix.ecosystem }}
33+
path: "cmd/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 Go
46+
uses: actions/setup-go@v6
47+
with:
48+
go-version: 'stable'
49+
50+
- name: Install dependencies
51+
run: make dev
52+
53+
- name: Regenerate FST
54+
id: regen_fst
55+
run: |-
56+
git pull
57+
make build-fst
58+
git diff --name-only | grep -q 'purls.fst' && echo "changed=true" >> $GITHUB_OUTPUT \
59+
|| echo "changed=false" >> $GITHUB_OUTPUT
60+
61+
# Commit latest FST
62+
git config user.name "AboutCode Automation"
63+
git config user.email "automation@aboutcode.org"
64+
git add purls.fst
65+
git commit -m "$(echo -e "Regenerate FST using latest PURLs\n\nSigned-off-by: AboutCode Automation <automation@aboutcode.org>")" || exit 0
66+
git push
67+
68+
- name: Bump minor version
69+
id: bump
70+
if: steps.regen_fst.outputs.changed == 'true'
71+
run: |-
72+
new_version=$(git tag --sort=version:refname | tail -n1 | awk -F'[v.]' '{ printf "v%d.%d.0\n", $2, $3+1 }')
73+
74+
echo "new_version=$new_version" >> $GITHUB_OUTPUT
75+
76+
- name: Add Changelog
77+
if: steps.regen_fst.outputs.changed == 'true'
78+
run: |-
79+
# Add Changelog
80+
today=$(date +%Y-%m-%d)
81+
awk -v ver="${{ steps.bump.outputs.new_version }}" -v date="$today" '
82+
NR==1{
83+
print "# Changelog\n\n## v" ver " (" date ")\n\n - Update FST with latest PURLs"
84+
next
85+
}1' CHANGELOG.md > .tmp.CHANGELOG.md && mv .tmp.CHANGELOG.md CHANGELOG.md
86+
87+
- name: Commit Changelog
88+
if: steps.regen_fst.outputs.changed == 'true'
89+
run: |-
90+
git config user.name "AboutCode Automation"
91+
git config user.email "automation@aboutcode.org"
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 <automation@aboutcode.org>")" || 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 }}"

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,18 @@
1212

1313
## Currently Supported Ecosystems
1414

15-
- **nuget**: [https://www.nuget.org/](https://www.nuget.org/)
15+
- **apk**
16+
- **cargo**
17+
- **composer**
18+
- **conan**
19+
- **cpan**
20+
- **cran**
21+
- **debain**
22+
- **maven**
23+
- **npm**
24+
- **nuget**
25+
- **pypi**
26+
- **swift**
1627

1728
## Usage
1829

cmd/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func main() {
5656

5757
func insert_purls(builder *vellum.Builder, file string) int {
5858
var err error
59+
// #nosec G304
5960
data, _ := os.ReadFile(file)
6061
lines := strings.FieldsFunc(string(data), func(r rune) bool {
6162
return r == '\n'

0 commit comments

Comments
 (0)