|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + |
| 7 | +jobs: |
| 8 | + release-please: |
| 9 | + name: Create Release |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + release_created: ${{ steps.release.outputs.release_created }} |
| 13 | + upload_url: ${{ steps.release.outputs.upload_url }} |
| 14 | + tag_name: ${{ steps.release.outputs.tag_name }} |
| 15 | + body: ${{ steps.release.outputs.body }} |
| 16 | + steps: |
| 17 | + - uses: GoogleCloudPlatform/[email protected] |
| 18 | + id: release |
| 19 | + with: |
| 20 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + release-type: ocaml |
| 22 | + package-name: libbinaryen |
| 23 | + |
| 24 | + add-archive: |
| 25 | + needs: [release-please] |
| 26 | + if: ${{ needs.release-please.outputs.release_created }} |
| 27 | + name: Add archive to release |
| 28 | + runs-on: macos-latest |
| 29 | + outputs: |
| 30 | + browser_download_url: ${{ steps.upload.outputs.browser_download_url }} |
| 31 | + steps: |
| 32 | + - name: Install git-archive-all |
| 33 | + run: | |
| 34 | + brew install git-archive-all |
| 35 | +
|
| 36 | + - name: Checkout code |
| 37 | + uses: actions/checkout@v2 |
| 38 | + with: |
| 39 | + submodules: 'recursive' |
| 40 | + |
| 41 | + - name: Build archive |
| 42 | + run: | |
| 43 | + git-archive-all --force-submodules libbinaryen.tar.gz |
| 44 | +
|
| 45 | + - name: Upload Release Asset |
| 46 | + id: upload |
| 47 | + uses: actions/upload-release-asset@v1 |
| 48 | + env: |
| 49 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + with: |
| 51 | + upload_url: ${{ needs.release-please.outputs.upload_url }} |
| 52 | + asset_path: ./libbinaryen.tar.gz |
| 53 | + asset_name: libbinaryen-${{ needs.release-please.outputs.tag_name }}.tar.gz |
| 54 | + asset_content_type: application/gzip |
| 55 | + |
| 56 | + opam-release: |
| 57 | + needs: [release-please, add-archive] |
| 58 | + name: Publish to opam registry |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - name: Setup bot user |
| 62 | + run: | |
| 63 | + git config --global user.email "[email protected]" |
| 64 | + git config --global user.name "Grain Bot" |
| 65 | +
|
| 66 | + # Some hacks to make sure opam doesn't pull the repo in a way we can't deal with |
| 67 | + - name: Setup opam repository |
| 68 | + run: | |
| 69 | + mkdir -p ~/.opam/plugins/opam-publish/repos/ |
| 70 | + git clone git://github.com/ocaml/opam-repository ~/.opam/plugins/opam-publish/repos/ocaml%opam-repository |
| 71 | + cd ~/.opam/plugins/opam-publish/repos/ocaml%opam-repository |
| 72 | + git remote add user https://${{ secrets.OPAM_RELEASE }}@github.com/grainbot/opam-repository |
| 73 | +
|
| 74 | + # Set up our token because opam doesn't support env var tokens |
| 75 | + - name: Setup token |
| 76 | + run: | |
| 77 | + mkdir -p ~/.opam/plugins/opam-publish/ |
| 78 | + echo -n ${{ secrets.OPAM_RELEASE }} > ~/.opam/plugins/opam-publish/libbinaryen.token |
| 79 | +
|
| 80 | + - name: Generate CHANGES file |
| 81 | + env: |
| 82 | + CHANGES: ${{ needs.release-please.outputs.body }} |
| 83 | + run: | |
| 84 | + echo -n "$CHANGES" > CHANGES.md |
| 85 | +
|
| 86 | + - name: Setup OCaml |
| 87 | + uses: ocaml/setup-ocaml@v2 |
| 88 | + with: |
| 89 | + ocaml-compiler: 4.12.0 |
| 90 | + |
| 91 | + - name: Install publish utils |
| 92 | + run: | |
| 93 | + opam install opam-publish |
| 94 | +
|
| 95 | + - name: Publish to opam |
| 96 | + run: | |
| 97 | + opam publish --no-browser --msg-file=CHANGES.md ${{ needs.add-archive.outputs.browser_download_url }} |
| 98 | +
|
| 99 | + npm-release: |
| 100 | + needs: [add-archive] |
| 101 | + name: Publish to npm registry |
| 102 | + runs-on: ubuntu-latest |
| 103 | + steps: |
| 104 | + - name: Setup NodeJS |
| 105 | + uses: actions/setup-node@v2 |
| 106 | + with: |
| 107 | + node-version: "14" |
| 108 | + registry-url: "https://registry.npmjs.org" |
| 109 | + |
| 110 | + - name: Publish to npm |
| 111 | + run: npm publish ${{ needs.add-archive.outputs.browser_download_url }} |
| 112 | + env: |
| 113 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_RELEASE }} |
0 commit comments