|
| 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 }}" |
0 commit comments