|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + draft_release: |
| 10 | + name: Create draft release |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Create Release |
| 17 | + id: create_release |
| 18 | + uses: actions/create-release@v1 |
| 19 | + env: |
| 20 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + with: |
| 22 | + tag_name: ${{ github.ref }} |
| 23 | + release_name: ${{ github.ref }} |
| 24 | + body: "" |
| 25 | + draft: true |
| 26 | + prerelease: false |
| 27 | + |
| 28 | + build_release: |
| 29 | + name: Build/upload release |
| 30 | + needs: draft_release |
| 31 | + runs-on: ${{ matrix.os }} |
| 32 | + strategy: |
| 33 | + matrix: |
| 34 | + os: [ ubuntu-latest, macOS-latest, windows-latest ] |
| 35 | + steps: |
| 36 | + - name: Set git to use LF |
| 37 | + run: | |
| 38 | + git config --global core.autocrlf false |
| 39 | + git config --global core.eol lf |
| 40 | + - uses: actions/checkout@v2 |
| 41 | + - name: Setup Haskell |
| 42 | + |
| 43 | + with: |
| 44 | + ghc-version: '8.6.5' |
| 45 | + stack-version: 'latest' |
| 46 | + enable-stack: true |
| 47 | + stack-no-global: true |
| 48 | + stack-setup-ghc: true |
| 49 | + - name: Setup node |
| 50 | + uses: actions/setup-node@v1 |
| 51 | + with: |
| 52 | + node-version: 10 |
| 53 | + # NB: We install gnu-tar because BSD tar is buggy on Github's macos machines, |
| 54 | + # and it breaks the cache: https://github.com/actions/cache/issues/403 |
| 55 | + - name: Install GNU tar (macOS) |
| 56 | + if: runner.os == 'macOS' |
| 57 | + run: | |
| 58 | + brew install gnu-tar |
| 59 | + echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH |
| 60 | +
|
| 61 | + - name: Package binary (Linux and macOS) |
| 62 | + if: runner.os != 'Windows' |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + stack install --dependencies-only |
| 66 | + mkdir artifacts |
| 67 | + stack build --copy-bins --local-bin-path ./artifacts |
| 68 | + cp artifacts/spago spago |
| 69 | + strip spago |
| 70 | + tar -zcvf "${{ matrix.os }}.tar.gz" spago |
| 71 | +
|
| 72 | + - name: Package binary (Windows) |
| 73 | + if: runner.os == 'Windows' |
| 74 | + shell: bash |
| 75 | + run: | |
| 76 | + stack install --dependencies-only |
| 77 | + stack build --copy-bins --local-bin-path ./artifacts |
| 78 | + cp artifacts/spago.exe spago.exe |
| 79 | + tar -zcvf windows.tar.gz spago.exe |
| 80 | +
|
| 81 | + - name: Upload Release Asset |
| 82 | + id: upload-release-asset |
| 83 | + uses: actions/upload-release-asset@v1 |
| 84 | + env: |
| 85 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + with: |
| 87 | + upload_url: ${{ needs.draft_release.outputs.upload_url }} |
| 88 | + asset_path: ./${{ matrix.os }}.tar.gz |
| 89 | + asset_name: ${{ matrix.os }}.tar.gz |
| 90 | + asset_content_type: application/gzip |
| 91 | + |
| 92 | + npm_publish: |
| 93 | + name: Publish package on npm |
| 94 | + needs: build_release |
| 95 | + runs-on: ubuntu-latest |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v2 |
| 98 | + - uses: actions/setup-node@v1 |
| 99 | + with: |
| 100 | + node-version: 10 |
| 101 | + - name: Prepare publish |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + sed -e "s/NPM_VERSION/$(./scripts/get-version)/g" -i npm/package.json |
| 105 | + sed -e "s/PACKAGE_VERSION/$(./scripts/get-version)/g" -i npm/install.js |
| 106 | + cd npm |
| 107 | + cp ../README.md ./README.md |
| 108 | + cp ../CONTRIBUTING.md ./CONTRIBUTING.md |
| 109 | + cp ../LICENSE ./LICENSE |
| 110 | + - name: Publish to NPM |
| 111 | + |
| 112 | + with: |
| 113 | + workspace: "npm" |
| 114 | + publish_args: "--non-interactive" |
| 115 | + env: |
| 116 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 117 | + NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments