Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add opam & npm releases to workflow #69

Merged
merged 1 commit into from Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitattributes
@@ -1,4 +1,2 @@
.github export-ignore
.ocamlformat export-ignore
yarn.lock export-ignore
package.json export-ignore
2 changes: 1 addition & 1 deletion .github/workflows/esy.yml
@@ -1,4 +1,4 @@
name: Binaryen.ml - esy workflow
name: Esy
on:
- push
- pull_request
Expand Down
57 changes: 0 additions & 57 deletions .github/workflows/opam-publish.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/opam.yml
@@ -1,4 +1,4 @@
name: Binaryen.ml - opam workflow
name: Opam
on:
- push
- pull_request
Expand Down
66 changes: 63 additions & 3 deletions .github/workflows/release.yml
@@ -1,4 +1,4 @@
name: Binaryen.ml Release
name: Release
on:
push:
branches:
Expand All @@ -12,6 +12,7 @@ jobs:
release_created: ${{ steps.release.outputs.release_created }}
upload_url: ${{ steps.release.outputs.upload_url }}
tag_name: ${{ steps.release.outputs.tag_name }}
body: ${{ steps.release.outputs.body }}
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
id: release
Expand All @@ -22,10 +23,12 @@ jobs:
bump-minor-pre-major: true

add-archive:
needs: release-please
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created }}
name: Add archive to release
runs-on: macos-latest
outputs:
browser_download_url: ${{ steps.upload.outputs.browser_download_url }}
steps:
- name: Install git-archive-all
run: |
Expand All @@ -41,7 +44,7 @@ jobs:
git-archive-all --force-submodules binaryen-archive.tar.gz

- name: Upload Release Asset
id: upload-release-asset
id: upload
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -50,3 +53,60 @@ jobs:
asset_path: ./binaryen-archive.tar.gz
asset_name: binaryen-archive-${{ needs.release-please.outputs.tag_name }}.tar.gz
asset_content_type: application/gzip

opam-release:
needs: [release-please, add-archive]
name: Publish to opam registry
runs-on: ubuntu-latest
steps:
- name: Setup bot user
run: |
git config --global user.email "bot@grain-lang.org"
git config --global user.name "Grain Bot"

# Some hacks to make sure opam doesn't pull the repo in a way we can't deal with
- name: Setup opam repository
run: |
mkdir -p ~/.opam/plugins/opam-publish/repos/
git clone git://github.com/ocaml/opam-repository ~/.opam/plugins/opam-publish/repos/ocaml%opam-repository
cd ~/.opam/plugins/opam-publish/repos/ocaml%opam-repository
git remote add user https://${{ secrets.OPAM_RELEASE }}@github.com/grainbot/opam-repository

# Set up our token because opam doesn't support env var tokens
- name: Setup token
run: |
mkdir -p ~/.opam/plugins/opam-publish/
echo -n ${{ secrets.OPAM_RELEASE }} > ~/.opam/plugins/opam-publish/binaryen.token

- name: Generate CHANGES file
run: |
echo -n "${{ needs.release-please.outputs.body }}" > CHANGES.md

- name: Setup OCaml
uses: avsm/setup-ocaml@v1
with:
ocaml-version: 4.11.1

- name: Install publish utils
run: |
opam install opam-publish

- name: Publish to opam
run: |
opam publish --no-browser --msg-file=CHANGES.md ${{ needs.add-archive.outputs.browser_download_url }}

npm-release:
needs: [add-archive]
name: Publish to npm registry
runs-on: ubuntu-latest
steps:
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: "14"
registry-url: "https://registry.npmjs.org"

- name: Publish to npm
run: npm publish ${{ needs.add-archive.outputs.browser_download_url }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_RELEASE }}