|
| 1 | +name: CoderBot Frontend Build and Publish as Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - v*.** |
| 6 | + |
| 7 | +jobs: |
| 8 | + release: |
| 9 | + name: Create GitHub Release |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v2 |
| 13 | + with: |
| 14 | + fetch-depth: 0 |
| 15 | + - name: Create Release |
| 16 | + id: create_release |
| 17 | + uses: actions/create-release@v1 |
| 18 | + env: |
| 19 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + with: |
| 21 | + tag_name: ${{ github.ref_name }} |
| 22 | + release_name: ${{ github.ref_name }} |
| 23 | + draft: ${{ contains( github.ref_name, 'rc' }} |
| 24 | + prerelease: false |
| 25 | + - name: Create artifact files |
| 26 | + run: | |
| 27 | + mkdir info |
| 28 | + echo "${{ steps.create_release.outputs.id }}" > info/release_id |
| 29 | + echo "${{ steps.create_release.outputs.upload_url }}" > info/upload_url |
| 30 | + - uses: actions/upload-artifact@v1 |
| 31 | + with: |
| 32 | + name: info |
| 33 | + path: info |
| 34 | + |
| 35 | + build: |
| 36 | + needs: [release] |
| 37 | + strategy: |
| 38 | + matrix: |
| 39 | + node-version: [16.x] |
| 40 | + runs-on: ubuntu-latest |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v2 |
| 43 | + - name: Use Node.js ${{ matrix.node-version }} |
| 44 | + uses: actions/setup-node@v2 |
| 45 | + with: |
| 46 | + node-version: ${{ matrix.node-version }} |
| 47 | + cache: 'npm' |
| 48 | + - run: npm ci |
| 49 | + - run: npm run build --if-present |
| 50 | + - name: Set upload_url |
| 51 | + id: upload_info |
| 52 | + run: | |
| 53 | + upload_url=$(cat info/upload_url) |
| 54 | + echo "::set-output name=upload_url::$upload_url" |
| 55 | +
|
| 56 | + - name: Create archive |
| 57 | + run: tar czf frontend.tar.gz dist |
| 58 | + |
| 59 | + - name: Upload Built Ruby |
| 60 | + uses: actions/upload-release-asset@v1 |
| 61 | + env: |
| 62 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + with: |
| 64 | + upload_url: ${{ steps.upload_info.outputs.upload_url }} |
| 65 | + asset_path: frontend.tar.gz |
| 66 | + asset_name: frontend.tar.gz |
| 67 | + asset_content_type: application/gzip |
| 68 | + |
| 69 | + metadata: |
| 70 | + name: Publish Release |
| 71 | + needs: [build] |
| 72 | + runs-on: ubuntu-latest |
| 73 | + steps: |
| 74 | + - uses: actions/download-artifact@v1 |
| 75 | + with: |
| 76 | + name: info |
| 77 | + - name: Set publish_info |
| 78 | + id: publish_info |
| 79 | + run: | |
| 80 | + release_id=$(cat info/release_id) |
| 81 | + echo "::set-output name=release_id::$release_id" |
| 82 | + - uses: eregon/publish-release@v1 |
| 83 | + env: |
| 84 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + with: |
| 86 | + release_id: ${{ steps.publish_info.outputs.release_id }} |
0 commit comments