Collect latest PURLs from FederatedCode and create release with latest FST #26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Collect latest PURLs from FederatedCode and create release with latest FST | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| permissions: | |
| contents: write | |
| jobs: | |
| collect-purls: | |
| strategy: | |
| max-parallel: 1 | |
| matrix: | |
| include: | |
| - ecosystem: apk | |
| - ecosystem: cargo | |
| - ecosystem: composer | |
| - ecosystem: conan | |
| - ecosystem: cpan | |
| - ecosystem: cran | |
| - ecosystem: debain | |
| - ecosystem: maven | |
| - ecosystem: npm | |
| - ecosystem: nuget | |
| - ecosystem: pypi | |
| - ecosystem: swift | |
| uses: ./.github/workflows/collect-purls_template.yml | |
| with: | |
| ecosystem: ${{ matrix.ecosystem }} | |
| path: "fst_builder/data/${{ matrix.ecosystem }}.txt" | |
| regen-fst-and-release: | |
| name: Regenerate FST and create release using new FST | |
| needs: collect-purls | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GH_TAG_RELEASE_TOKEN }} | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install cargo-edit | |
| run: cargo install cargo-edit | |
| - name: Regenerate FST | |
| id: regen_fst | |
| run: |- | |
| git pull | |
| make build-fst | |
| git diff --name-only | grep -q 'purls.fst' && echo "changed=true" >> $GITHUB_OUTPUT \ | |
| || echo "changed=false" >> $GITHUB_OUTPUT | |
| # Commit latest FST | |
| git config user.name "AboutCode Automation" | |
| git config user.email "[email protected]" | |
| git add purls.fst | |
| git commit -m "$(echo -e "Regenerate FST using latest PURLs\n\nSigned-off-by: AboutCode Automation <[email protected]>")" || exit 0 | |
| git push | |
| - name: Bump minor version | |
| id: bump | |
| if: steps.regen_fst.outputs.changed == 'true' | |
| run: |- | |
| output=$(cargo set-version --bump minor 2>&1) | |
| new_version=$(echo "$output" | awk '{print $NF}') | |
| echo "new_version=$new_version" >> $GITHUB_OUTPUT | |
| - name: Add Changelog | |
| if: steps.regen_fst.outputs.changed == 'true' | |
| run: |- | |
| # Add Changelog | |
| today=$(date +%Y-%m-%d) | |
| awk -v ver="${{ steps.bump.outputs.new_version }}" -v date="$today" ' | |
| NR==1{ | |
| print "# Changelog\n\n## v" ver " (" date ")\n\n - Update FST with latest PURLs" | |
| next | |
| }1' CHANGELOG.md > .tmp.CHANGELOG.md && mv .tmp.CHANGELOG.md CHANGELOG.md | |
| - name: Commit Changelog and Lock files | |
| if: steps.regen_fst.outputs.changed == 'true' | |
| run: |- | |
| # Commit Changelog and Lock files | |
| git config user.name "AboutCode Automation" | |
| git config user.email "[email protected]" | |
| git add -A | |
| 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 | |
| git push | |
| - name: Push tag | |
| if: steps.regen_fst.outputs.changed == 'true' | |
| run: |- | |
| # Push tag | |
| git tag -a "v${{ steps.bump.outputs.new_version }}" -m "Release v${{ steps.bump.outputs.new_version }}" | |
| git push origin "v${{ steps.bump.outputs.new_version }}" |