Release Artifacts #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a copy-and-paste version of ci.yml but additionally creating a release | |
name: Release Artifacts | |
on: | |
push: | |
tags: | |
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | |
workflow_run: | |
workflows: ["Create Version and Tag"] # 'autorelease.yml' | |
types: | |
- completed | |
env: | |
JAVA_VERSION: '11' | |
NODE_VERSION: '12.x' | |
jobs: | |
build-jar: | |
name: Build and assemble the Effekt compiler | |
runs-on: ubuntu-latest | |
if: > | |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || | |
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') | |
outputs: | |
version: ${{ steps.get_version.outputs.VERSION }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: 'true' | |
- name: Set up JDK ${{ env.JAVA_VERSION }} | |
uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ env.JAVA_VERSION }} | |
distribution: 'zulu' | |
cache: 'sbt' | |
- name: Set up NodeJS ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Get the version | |
id: get_version | |
run: | | |
if [ "${{ github.event_name }}" = "push" ]; then | |
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
elif [ "${{ github.event_name }}" = "workflow_run" ]; then | |
# For workflow_run event, we need to fetch the tag created in the previous workflow | |
git fetch --tags | |
LATEST_TAG=$(git describe --tags --abbrev=0) | |
echo "VERSION=${LATEST_TAG#v}" >> $GITHUB_OUTPUT | |
else | |
echo "Unsupported event type: ${{ github.event_name }}" | |
exit 1 | |
fi | |
- name: Assemble jar file | |
run: sbt clean deploy | |
- name: Generate npm package | |
run: mv $(npm pack) effekt.tgz | |
- name: Upload Effekt binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: effekt | |
path: bin/effekt | |
- name: Upload the npm package | |
uses: actions/upload-artifact@v4 | |
with: | |
name: effekt-npm-package | |
path: effekt.tgz | |
release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
needs: [build-jar] | |
steps: | |
- name: Download JAR artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: effekt | |
path: distribution/ | |
- name: Download npm package | |
uses: actions/download-artifact@v4 | |
with: | |
name: effekt-npm-package | |
path: distribution/ | |
# Generates nice release notes according to https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes | |
# We can also configure these down the road: https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes | |
- name: Generate Release Notes | |
id: generate_release_notes | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const { data } = await github.rest.repos.generateReleaseNotes({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag_name: 'v${{ needs.build-jar.outputs.version }}', | |
}); | |
core.setOutput('name', data.name); | |
core.setOutput('body', data.body); | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
release_name: Release v${{ needs.build-jar.outputs.version }} | |
tag_name: v${{ needs.build-jar.outputs.version }} | |
body: ${{ steps.generate_release_notes.outputs.body }} | |
draft: false | |
prerelease: false | |
- name: Upload jar file | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./distribution/effekt | |
asset_name: effekt.jar | |
asset_content_type: application/java-archive | |
- name: Upload npm package | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./distribution/effekt.tgz | |
asset_name: effekt.tgz | |
asset_content_type: application/gzip | |
publish-npm: | |
name: Publish NPM Package | |
runs-on: ubuntu-latest | |
needs: [build-jar, release] | |
steps: | |
- name: Download npm package | |
uses: actions/download-artifact@v4 | |
with: | |
name: effekt-npm-package | |
- name: Set up NodeJS ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
registry-url: 'https://registry.npmjs.org' | |
- name: Publish to NPM as @effekt-lang/effekt | |
run: npm publish effekt.tgz --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |