Publish release assets #41
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: Publish release assets | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 */4 * * *" | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: publish-release-assets | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install dependencies | |
| run: npm install --no-audit --no-fund | |
| - name: Set tag | |
| run: echo "TAG=data-$(date -u +'%Y%m%d-%H%M')" >> "$GITHUB_ENV" | |
| - name: Set month key | |
| run: echo "MONTH_KEY=$(date -u +'%Y-%m')" >> "$GITHUB_ENV" | |
| - name: Seed monthly archive | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| mkdir -p monthly-seed | |
| gh release download --repo "${GITHUB_REPOSITORY}" --pattern "monthly-${MONTH_KEY}-archive.sqlite" --dir monthly-seed --clobber || true | |
| - name: Generate release assets | |
| env: | |
| MW_OUTPUT_DIR: release-assets | |
| MW_CONCURRENCY: "12" | |
| MW_RETRY_COUNT: "3" | |
| MW_RETRY_DELAY_MS: "90000" | |
| MW_RETRY_BACKOFF: "2" | |
| MW_RETRY_JITTER_MS: "15000" | |
| MW_IP_SHARD_GROUP_SIZE: "16" | |
| MW_RANGE_SHARD_GROUP_SIZE: "16" | |
| MW_MAP_TOPN: "50000" | |
| MW_MONTHLY: "1" | |
| MW_MONTHLY_DB_PATH: release-assets/monthly-${{ env.MONTH_KEY }}-archive.sqlite | |
| MW_MONTHLY_SEED_PATH: monthly-seed/monthly-${{ env.MONTH_KEY }}-archive.sqlite | |
| MW_WRITE_JSONL: "0" | |
| run: | | |
| rm -rf release-assets | |
| npm run generate:site | |
| - name: Update monthly index | |
| run: | | |
| node scripts/update-monthly-index.js \ | |
| --index docs/data/monthly/index.json \ | |
| --month "${MONTH_KEY}" \ | |
| --release-base "https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}/" \ | |
| --archive "monthly-${MONTH_KEY}-archive.sqlite" \ | |
| --map-pattern "monthly-${MONTH_KEY}-map_{type}.geojson" \ | |
| --stats-pattern "monthly-${MONTH_KEY}-stats_{type}.json" | |
| - name: Commit monthly index | |
| run: | | |
| if git diff --quiet -- docs/data/monthly/index.json; then | |
| echo "Monthly index unchanged." | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add docs/data/monthly/index.json | |
| git commit -m "Update monthly index for ${MONTH_KEY}" | |
| git push | |
| - name: Checksums | |
| run: | | |
| cd release-assets | |
| find . -maxdepth 1 -type f -print0 | xargs -0 sha256sum > SHA256SUMS.txt | |
| - name: Create GitHub Release and upload assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.TAG }} | |
| name: MalwareWorld data ${{ env.TAG }} | |
| make_latest: true | |
| files: | | |
| release-assets/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare Pages artifact (docs + data) | |
| run: | | |
| rm -rf pages | |
| mkdir -p pages | |
| cp -R docs/. pages/ | |
| mkdir -p pages/data | |
| rsync -av \ | |
| --exclude "monthly-*-archive.sqlite" \ | |
| --exclude "monthly-*-map_*.geojson" \ | |
| --exclude "monthly-*-stats_*.json" \ | |
| release-assets/ pages/data/ | |
| - name: Configure Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: pages | |
| - name: Deploy Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |