|
| 1 | +name: GitHub Release |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Runs at 07:30 Asia/Shanghai (UTC+8) => 23:30 UTC (previous day) |
| 6 | + - cron: '30 23 * * *' |
| 7 | + push: |
| 8 | + branches: [ release ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + # 1. Build artifacts in parallel |
| 12 | + build: |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04] |
| 16 | + runs-on: ubuntu-latest |
| 17 | + container: ghcr.io/openxiangshan/${{ matrix.os }}:latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + submodules: recursive |
| 23 | + |
| 24 | + - name: Build libfuzzer.a on ${{ matrix.os }} |
| 25 | + run: | |
| 26 | + # install Rust |
| 27 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 28 | + source $HOME/.cargo/env |
| 29 | + cargo install cargo-make |
| 30 | + # build libfuzzer.a |
| 31 | + make build |
| 32 | + # rename it before upload |
| 33 | + # downloaded artifacts will have original names (different from the artifact name) |
| 34 | + mv target/release/libfuzzer.a libfuzzer-${{ matrix.os }}.a |
| 35 | +
|
| 36 | + - name: Upload artifact for ${{ matrix.os }} |
| 37 | + uses: actions/upload-artifact@v4 |
| 38 | + with: |
| 39 | + name: libfuzzer-${{ matrix.os }}.a |
| 40 | + path: libfuzzer-${{ matrix.os }}.a |
| 41 | + |
| 42 | + # 2. Create release if there are new commits since last tag |
| 43 | + release: |
| 44 | + needs: build |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - uses: actions/download-artifact@v4 |
| 50 | + with: |
| 51 | + merge-multiple: true |
| 52 | + |
| 53 | + - name: Fetch all tags |
| 54 | + run: git fetch --tags |
| 55 | + |
| 56 | + - name: Check for commits since last release |
| 57 | + id: check_changes |
| 58 | + run: | |
| 59 | + LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) || echo "") |
| 60 | + if [ -z "$LATEST_TAG" ]; then |
| 61 | + echo "::set-output name=changed::true" |
| 62 | + else |
| 63 | + COUNT=$(git rev-list ${LATEST_TAG}..HEAD --count) |
| 64 | + if [ "$COUNT" -gt 0 ]; then |
| 65 | + echo "::set-output name=changed::true" |
| 66 | + else |
| 67 | + echo "::set-output name=changed::false" |
| 68 | + fi |
| 69 | + fi |
| 70 | + shell: bash |
| 71 | + |
| 72 | + - name: Set release date (UTC+8) |
| 73 | + id: vars |
| 74 | + run: echo "RELEASE_DATE=$(date -u -d '8 hours' +'%Y-%m-%d')" >> $GITHUB_ENV |
| 75 | + |
| 76 | + - name: Create Git tag |
| 77 | + if: steps.check_changes.outputs.changed == 'true' |
| 78 | + run: | |
| 79 | + git config user.name "github-actions[bot]" |
| 80 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 81 | + git tag -a "${{ env.RELEASE_DATE }}" -m "Release ${{ env.RELEASE_DATE }}" |
| 82 | + git push origin "${{ env.RELEASE_DATE }}" |
| 83 | +
|
| 84 | + - name: Create Release |
| 85 | + if: steps.check_changes.outputs.changed == 'true' |
| 86 | + uses: softprops/action-gh-release@v2 |
| 87 | + with: |
| 88 | + tag_name: ${{ env.RELEASE_DATE }} |
| 89 | + name: ${{ env.RELEASE_DATE }} |
| 90 | + make_latest: 'true' |
| 91 | + fail_on_unmatched_files: true |
| 92 | + preserve_order: true |
| 93 | + files: | |
| 94 | + libfuzzer-ubuntu-20.04.a |
| 95 | + libfuzzer-ubuntu-22.04.a |
| 96 | + libfuzzer-ubuntu-24.04.a |
0 commit comments