|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + upgrade: |
| 7 | + description: Type of version upgrade (patch, minor, major) |
| 8 | + required: true |
| 9 | + default: patch |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + - uses: actions/setup-node@v2-beta |
| 17 | + with: |
| 18 | + node-version: 12 |
| 19 | + registry-url: https://registry.npmjs.org/ |
| 20 | + |
| 21 | + - name: Setup git |
| 22 | + run: |- |
| 23 | + git config --global user.name "github-actions[bot]" |
| 24 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 25 | + |
| 26 | + - run: npm version ${{ github.event.inputs.upgrade }} |
| 27 | + |
| 28 | + - run: git push |
| 29 | + - run: git push --tags |
| 30 | + |
| 31 | + - run: npm publish |
| 32 | + env: |
| 33 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 34 | + |
| 35 | + - name: Prepare build |
| 36 | + run: npm i -g pkg |
| 37 | + |
| 38 | + - name: Build |
| 39 | + run: pkg --out-path build . |
| 40 | + |
| 41 | + - name: Get version and package name |
| 42 | + id: get_info |
| 43 | + run: |- |
| 44 | + version=$(node -p "require('./package.json').version") |
| 45 | + echo $version |
| 46 | + echo "::set-output name=version::$version" |
| 47 | + name=$(node -p "require('./package.json').name") |
| 48 | + echo $name |
| 49 | + echo "::set-output name=name::$name" |
| 50 | +
|
| 51 | + - name: Create Release |
| 52 | + id: create_release |
| 53 | + uses: actions/create-release@v1 |
| 54 | + env: |
| 55 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + with: |
| 57 | + tag_name: v${{ steps.get_info.outputs.version }} |
| 58 | + release_name: Release v${{ steps.get_info.outputs.version }} |
| 59 | + draft: false |
| 60 | + prerelease: false |
| 61 | + |
| 62 | + - name: Upload Linux Binary |
| 63 | + uses: actions/upload-release-asset@v1 |
| 64 | + env: |
| 65 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + with: |
| 67 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 68 | + asset_path: ./build/${{ steps.get_info.outputs.name }}-linux |
| 69 | + asset_name: ${{ steps.get_info.outputs.name }}-linux |
| 70 | + asset_content_type: application/x-executable |
| 71 | + |
| 72 | + - name: Upload MacOS Binary |
| 73 | + uses: actions/upload-release-asset@v1 |
| 74 | + env: |
| 75 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + with: |
| 77 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 78 | + asset_path: ./build/${{ steps.get_info.outputs.name }}-macos |
| 79 | + asset_name: ${{ steps.get_info.outputs.name }}-macos |
| 80 | + asset_content_type: application/x-mach-binary |
| 81 | + |
| 82 | + - name: Upload Windows Binary |
| 83 | + uses: actions/upload-release-asset@v1 |
| 84 | + env: |
| 85 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + with: |
| 87 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 88 | + asset_path: ./build/${{ steps.get_info.outputs.name }}-win.exe |
| 89 | + asset_name: ${{ steps.get_info.outputs.name }}-win.exe |
| 90 | + asset_content_type: application/x-dosexec |
0 commit comments