|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + name: Release |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Create draft release |
| 15 | + uses: actions/github-script@0.9.0 |
| 16 | + with: |
| 17 | + github-token: ${{secrets.GITHUB_TOKEN}} |
| 18 | + script: | |
| 19 | + const fs = require('fs'); |
| 20 | +
|
| 21 | + const release = await github.repos.createRelease({ |
| 22 | + owner: context.repo.owner, |
| 23 | + repo: context.repo.repo, |
| 24 | + tag_name: new Date().toISOString().replace(/[T:]/g, '-').split('.')[0], |
| 25 | + target_commitish: context.sha, |
| 26 | + draft: true, |
| 27 | + prerelease: true, |
| 28 | + }); |
| 29 | +
|
| 30 | + fs.mkdirSync('release-info'); |
| 31 | + fs.writeFileSync('release-info/release.json', JSON.stringify({ |
| 32 | + id: release.data.id, |
| 33 | + upload_url: release.data.upload_url, |
| 34 | + })); |
| 35 | +
|
| 36 | + - name: Upload release-info |
| 37 | + uses: actions/upload-artifact@v1 |
| 38 | + with: |
| 39 | + name: release-info |
| 40 | + path: release-info |
| 41 | + |
| 42 | + build: |
| 43 | + name: ${{ matrix.wheel }} |
| 44 | + runs-on: ubuntu-latest |
| 45 | + needs: release |
| 46 | + container: |
| 47 | + image: debian:10 |
| 48 | + |
| 49 | + strategy: |
| 50 | + matrix: |
| 51 | + wheel: |
| 52 | + - ns-3 |
| 53 | + fail-fast: false |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Checkout code |
| 57 | + uses: actions/checkout@v2 |
| 58 | + |
| 59 | + - name: Execute ${{ matrix.wheel }}/build.sh |
| 60 | + run: exec ${{ matrix.wheel }}/build.sh |
| 61 | + |
| 62 | + - name: Download release-info |
| 63 | + uses: actions/download-artifact@v1 |
| 64 | + with: |
| 65 | + name: release-info |
| 66 | + |
| 67 | + - name: Upload ${{ matrix.wheel }} |
| 68 | + uses: actions/github-script@0.9.0 |
| 69 | + with: |
| 70 | + github-token: ${{secrets.GITHUB_TOKEN}} |
| 71 | + script: | |
| 72 | + const fs = require('fs'); |
| 73 | +
|
| 74 | + const release = JSON.parse(fs.readFileSync('release-info/release.json'), 'utf8'); |
| 75 | + const path = process.env.ASSET_PATH; |
| 76 | + const name = process.env.ASSET_NAME; |
| 77 | + const data = fs.readFileSync(path); |
| 78 | +
|
| 79 | + await github.repos.uploadReleaseAsset({ |
| 80 | + url: release.upload_url, |
| 81 | + headers: { |
| 82 | + 'content-type': 'application/zip', |
| 83 | + 'content-length': data.length, |
| 84 | + }, |
| 85 | + name, |
| 86 | + data, |
| 87 | + }); |
| 88 | +
|
| 89 | + publish: |
| 90 | + name: Publish |
| 91 | + runs-on: ubuntu-latest |
| 92 | + needs: build |
| 93 | + |
| 94 | + steps: |
| 95 | + - name: Download release-info |
| 96 | + uses: actions/download-artifact@v1 |
| 97 | + with: |
| 98 | + name: release-info |
| 99 | + |
| 100 | + - name: Publish release |
| 101 | + uses: actions/github-script@0.9.0 |
| 102 | + with: |
| 103 | + github-token: ${{secrets.GITHUB_TOKEN}} |
| 104 | + script: | |
| 105 | + const fs = require('fs'); |
| 106 | +
|
| 107 | + const release = JSON.parse(fs.readFileSync('release-info/release.json'), 'utf8'); |
| 108 | +
|
| 109 | + await github.repos.updateRelease({ |
| 110 | + owner: context.repo.owner, |
| 111 | + repo: context.repo.repo, |
| 112 | + release_id: release.id, |
| 113 | + draft: false, |
| 114 | + }); |
0 commit comments