|
| 1 | +# https://github.com/actions/upload-release-asset |
| 2 | + |
| 3 | +# This is the command I used to test on a fork of the repo |
| 4 | +# git add . && git commit -m a && npm version patch && git push && git push --tags |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + # Sequence of patterns matched against refs/tags |
| 9 | + tags: |
| 10 | + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 |
| 11 | + |
| 12 | +name: Upload Release Asset |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: Upload Release Asset |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + node-version: [14.15.3] |
| 21 | + steps: |
| 22 | + - name: Use Node.js ${{ matrix.node-version }} |
| 23 | + uses: actions/setup-node@v1 |
| 24 | + with: |
| 25 | + node-version: ${{ matrix.node-version }} |
| 26 | + - name: Checkout code |
| 27 | + uses: actions/checkout@v1 |
| 28 | + - name: Get the file name |
| 29 | + id: get_file_name |
| 30 | + run: echo ::set-output name=result::rederly-$(git describe)-backend |
| 31 | + - name: NPM install |
| 32 | + uses: bahmutov/npm-install@v1 |
| 33 | + - name: Build and package |
| 34 | + run: npm run build:package |
| 35 | + env: |
| 36 | + REDERLY_PACKAGER_DEST_FILE: ${{ steps.get_file_name.outputs.result }} |
| 37 | + # Can't preserve packages because try build will find the node module in the parent directory |
| 38 | + REDERLY_PACKAGER_PRESERVE_NODE_MODULES: false |
| 39 | + CI: false # TODO Linting errors cause the build to fail when CI is true (default) |
| 40 | + - name: Try build |
| 41 | + run: npm --prefix build run cli:built noop |
| 42 | + env: |
| 43 | + DB_SYNC: false |
| 44 | + FAIL_ON_MISSING_CONFIGURATIONS: false |
| 45 | + - name: Create Release |
| 46 | + id: create_release |
| 47 | + uses: actions/create-release@v1 |
| 48 | + env: |
| 49 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + with: |
| 51 | + tag_name: ${{ github.ref }} |
| 52 | + release_name: Release ${{ github.ref }} |
| 53 | + draft: false |
| 54 | + prerelease: true |
| 55 | + - name: Upload Release Asset (zip) |
| 56 | + id: upload-release-asset-zip |
| 57 | + uses: actions/upload-release-asset@v1 |
| 58 | + env: |
| 59 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + with: |
| 61 | + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps |
| 62 | + asset_path: ./package-outputs/${{ steps.get_file_name.outputs.result }}.zip |
| 63 | + asset_name: ${{ steps.get_file_name.outputs.result }}.zip |
| 64 | + asset_content_type: application/zip |
| 65 | + - name: Upload Release Asset (tgz) |
| 66 | + id: upload-release-asset-tgz |
| 67 | + uses: actions/upload-release-asset@v1 |
| 68 | + env: |
| 69 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + with: |
| 71 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 72 | + asset_path: ./package-outputs/${{ steps.get_file_name.outputs.result }}.tgz |
| 73 | + asset_name: ${{ steps.get_file_name.outputs.result }}.tgz |
| 74 | + asset_content_type: application/gzip |
0 commit comments