|
| 1 | +name: CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "master" ] |
| 6 | + tags: [ "*" ] |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v2 |
| 14 | + - uses: actions/setup-node@v2 |
| 15 | + |
| 16 | + - name: Setup dependencies |
| 17 | + run: npm install |
| 18 | + |
| 19 | + - name: Build xsnippet-web |
| 20 | + run: npm run build |
| 21 | + |
| 22 | + - name: Create xsnippet-web.tar.gz |
| 23 | + run: tar cvzf xsnippet-web.tar.gz -C dist/ . |
| 24 | + |
| 25 | + - name: Setup release metadata |
| 26 | + run: | |
| 27 | + PRERELEASE=true |
| 28 | + VERSION=nightly |
| 29 | +
|
| 30 | + if [[ $GITHUB_REF =~ ^refs/tags/ ]]; then |
| 31 | + if [[ $GITHUB_REF =~ ^refs/tags/v[0-9]+\.[0-9]+(\.[0-9]+)*$ ]]; then |
| 32 | + PRERELEASE=false |
| 33 | + fi |
| 34 | + VERSION="${GITHUB_REF#refs/tags/}" |
| 35 | + fi |
| 36 | +
|
| 37 | + echo ::set-output name=version::${VERSION} |
| 38 | + echo ::set-output name=prerelease::${PRERELEASE} |
| 39 | + id: metadata |
| 40 | + |
| 41 | + # Since 'softprops/action-gh-release@v1' does not support release |
| 42 | + # re-creation, we have to remove 'nightly' release first. |
| 43 | + - name: Remove nightly release |
| 44 | + run: | |
| 45 | + gh release delete nightly --yes || true |
| 46 | + git push origin :nightly || true |
| 47 | + env: |
| 48 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + if: steps.metadata.outputs.version == 'nightly' |
| 50 | + |
| 51 | + - name: Create github release |
| 52 | + uses: softprops/action-gh-release@v1 |
| 53 | + with: |
| 54 | + tag_name: ${{ steps.metadata.outputs.version }} |
| 55 | + prerelease: ${{ steps.metadata.outputs.prerelease}} |
| 56 | + target_commitish: ${{ github.sha }} |
| 57 | + files: ./xsnippet-web.tar.gz |
| 58 | + generate_release_notes: true |
| 59 | + fail_on_unmatched_files: true |
0 commit comments