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

Move to a weekly release scheme #538

Merged
merged 23 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
355bd1d
Move to a weekly release scheme
jiribenes Aug 9, 2024
5b34373
Split CI into two parts: tagging automatically & releasing; add NPM
jiribenes Aug 27, 2024
1c9f9f0
Remove one of the NPM packages
jiribenes Aug 27, 2024
d81fd0a
Backport: bump action versions
jiribenes Aug 30, 2024
fb812ba
Backport: update MVN & NPM versions via sbt
jiribenes Aug 30, 2024
658f205
Backport: determine deploy version correctly
jiribenes Aug 30, 2024
0219254
Backport: generate pretty release notes
jiribenes Aug 30, 2024
fd37230
Modify NPM command: add provenance, remove scope
jiribenes Aug 30, 2024
30e1961
Fix manual push
jiribenes Aug 30, 2024
9c5df5e
Backport: bump minor version every time
jiribenes Sep 2, 2024
d34effc
Backport: correct version resolution
jiribenes Sep 3, 2024
57a8332
Minimise diff, backport action version bumps
jiribenes Sep 3, 2024
4d37de7
Backport: bump setup-java version to v4
jiribenes Sep 3, 2024
dc7f94d
Update package.json
jiribenes Sep 9, 2024
73c577e
Fix 'sbt install' since npm package has a different name
jiribenes Sep 9, 2024
d510c25
Try fixing the path to the Effekt binary
jiribenes Sep 9, 2024
d33ce97
Backport: separate version file
jiribenes Sep 9, 2024
6a08574
Backport: fixes regarding separate version file
jiribenes Sep 9, 2024
93e124c
Backport: Move tests to autorelease.yml
jiribenes Sep 9, 2024
d28fc48
Backport: run tests with retry in autorelease
jiribenes Sep 9, 2024
23884ac
Backport: proper retry command, rerun only failed tests
jiribenes Sep 9, 2024
e8b2d83
Backport: nicer text description of tasks & DRY
jiribenes Sep 10, 2024
27e66d6
Backport: Use env for a correct NodeJS/Java version
jiribenes Sep 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .github/workflows/autorelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Create Version and Tag
# If you change this name, don't forget to change the name in 'deploy.yml'!

on:
schedule:
- cron: '0 3 * * 1' # Every Monday at 3am UTC
workflow_dispatch: # For manual triggering

env:
JAVA_VERSION: '11'
NODE_VERSION: '12.x'

jobs:
run-tests: # redux of usual CI defined in `ci.yml`
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
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: Install MLton
run: |
curl -L https://github.com/MLton/mlton/releases/download/on-20210117-release/mlton-20210117-1.amd64-linux-glibc2.31.tgz --output mlton.tgz
tar -xzf mlton.tgz
mv mlton-20210117-1.amd64-linux-glibc2.31 $GITHUB_WORKSPACE/mlton
chmod +x $GITHUB_WORKSPACE/mlton/bin/mlton
echo "Trying to call directly"
$GITHUB_WORKSPACE/mlton/bin/mlton
echo "Adding mlton to path"
echo "$GITHUB_WORKSPACE/mlton/bin" >> $GITHUB_PATH

- name: Install Chez Scheme, LLVM & libuv
run: sudo apt-get install -y chezscheme llvm-15 libuv1-dev

- name: Run tests with retry
uses: nick-fields/retry@v3
with:
timeout_minutes: 120 # NOTE: This needs _some_ value. As of writing this, 2 hours should be future-proof. :)
max_attempts: 3
retry_on: error
command: sbt clean test
new_command_on_retry: sbt testQuick # should only rerun failed tests

bump-version-and-tag:
name: Bump Version and Create Tag
runs-on: ubuntu-latest
needs: [run-tests]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'true'

# No need to setup environment again

- name: Bump Effekt version using sbt
id: set-version
run: |
# Capture the output of 'sbt bumpMinorVersion'
full_output=$(sbt 'bumpMinorVersion' -error)

# Extract the actual version number using grep
new_version=$(echo "$full_output" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | tail -n 1)

# Trim any potential whitespace
new_version=$(echo "$new_version" | xargs)

# Check that the new_version is actually non-empty and looks like a version number
if [[ ! $new_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version bump failed. Invalid version number: '${new_version}'"
echo "Full output was:"
echo "$full_output"
exit 1
fi

echo "VERSION=${new_version}" >> $GITHUB_OUTPUT
echo "Successfully set new version: ${new_version}"

- name: Update Effekt version in NPM and MVN via sbt
run: sbt updateVersions

- name: Commit and push changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions[bot]"
git add project/EffektVersion.scala
git add package.json
git add pom.xml
git commit -m "Bump version to ${{ steps.set-version.outputs.VERSION }}"
git push

- name: Create and push tag
run: |
git tag v${{ steps.set-version.outputs.VERSION }}
git push origin v${{ steps.set-version.outputs.VERSION }}
129 changes: 89 additions & 40 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,76 @@
# This is a copy-and-past version of ci.yml but additionally creating a release
# 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 Effekt compiler and run tests
name: Build and assemble the Effekt compiler
runs-on: ubuntu-latest
steps:
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 }}

- uses: actions/checkout@v2
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'true'

- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: 11
java-version: ${{ env.JAVA_VERSION }}
distribution: 'zulu'
cache: 'sbt'

- name: Set up NodeJS
uses: actions/setup-node@v1
- name: Set up NodeJS ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: '12.x'
node-version: ${{ env.NODE_VERSION }}

- name: Install MLton
- name: Get the version
id: get_version
run: |
curl -L https://github.com/MLton/mlton/releases/download/on-20210117-release/mlton-20210117-1.amd64-linux-glibc2.31.tgz --output mlton.tgz
tar -xzf mlton.tgz
mv mlton-20210117-1.amd64-linux-glibc2.31 $GITHUB_WORKSPACE/mlton
chmod +x $GITHUB_WORKSPACE/mlton/bin/mlton
echo "Trying to call directly"
$GITHUB_WORKSPACE/mlton/bin/mlton
echo "Adding mlton to path"
echo "$GITHUB_WORKSPACE/mlton/bin" >> $GITHUB_PATH

- name: Install Chez Scheme
run: sudo apt-get install chezscheme

- name: Run tests and assemble jar file
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

- id: npmpackage
name: Generate npm package
- name: Generate npm package
run: mv $(npm pack) effekt.tgz

- name: Upload Effekt binary
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: effekt
path: bin/effekt

- name: Upload the npm package
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: effekt-npm-package
path: effekt.tgz
Expand All @@ -63,35 +80,47 @@ jobs:
runs-on: ubuntu-latest
needs: [build-jar]
steps:
- name: Checkout code
uses: actions/checkout@master

- name: Download JAR artifact
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4
with:
name: effekt
path: distribution/

- name: Download npm package
uses: actions/download-artifact@v1
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@latest
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_name: Prerelease ${{ github.ref }}
tag_name: ${{ github.ref }}
body: Automatic release for ${{ github.ref }}
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: true
prerelease: false

jiribenes marked this conversation as resolved.
Show resolved Hide resolved
- name: Upload jar file
id: upload_jar
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -102,7 +131,6 @@ jobs:
asset_content_type: application/java-archive

- name: Upload npm package
id: upload_npm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -111,3 +139,24 @@ jobs:
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 }}
2 changes: 1 addition & 1 deletion bin/effekt.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
java -jar "$(npm root -g)/effekt/bin/effekt" $@
java -jar "$(npm root -g)/@effekt-lang/effekt/bin/effekt" $@
jiribenes marked this conversation as resolved.
Show resolved Hide resolved
27 changes: 24 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import sbtcrossproject.CrossProject

import scala.sys.process.Process
import benchmarks._
import EffektVersion.effektVersion

// additional targets that can be used in sbt
lazy val deploy = taskKey[Unit]("Builds the jar and moves it to the bin folder")
Expand All @@ -11,8 +12,7 @@ lazy val install = taskKey[Unit]("Installs the current version locally")
lazy val assembleJS = taskKey[Unit]("Assemble the JS file in out/effekt.js")
lazy val assembleBinary = taskKey[Unit]("Assembles the effekt binary in bin/effekt")
lazy val generateDocumentation = taskKey[Unit]("Generates some documentation.")

lazy val effektVersion = "0.2.2"
lazy val bumpMinorVersion = taskKey[Unit]("Bumps the minor version number (used in CI).")

lazy val noPublishSettings = Seq(
publish := {},
Expand Down Expand Up @@ -144,7 +144,7 @@ lazy val effekt: CrossProject = crossProject(JSPlatform, JVMPlatform).in(file("e
assembleBinary.value

Process(s"${npm.value} pack").!!
Process(s"${npm.value} install -g effekt-${effektVersion}.tgz").!!
Process(s"${npm.value} install -g effekt-lang-effekt-${effektVersion}.tgz").!!
},

generateLicenses := {
Expand All @@ -160,6 +160,27 @@ lazy val effekt: CrossProject = crossProject(JSPlatform, JVMPlatform).in(file("e
Process(s"${npm.value} version ${effektVersion} --no-git-tag-version --allow-same-version").!!
Process(s"${mvn.value} versions:set -DnewVersion=${effektVersion} -DgenerateBackupPoms=false").!!
},

bumpMinorVersion := {
val versionPattern = """(\d+)\.(\d+)\.(\d+)""".r
val newVersion = effektVersion match {
case versionPattern(major, minor, patch) =>
s"$major.${minor.toInt + 1}.0"
case _ =>
sys.error(s"Invalid version format: $effektVersion")
}

val versionFile = (ThisBuild / baseDirectory).value / "project" / "EffektVersion.scala"
IO.write(versionFile,
s"""// Don't change this file without changing the CI too!
|import sbt.*
|import sbt.Keys.*
|object EffektVersion { lazy val effektVersion = "$newVersion" }
|""".stripMargin)

println(newVersion)
},

generateDocumentation := TreeDocs.replacer.value,
Compile / sourceGenerators += versionGenerator.taskValue,
Compile / sourceGenerators += TreeDocs.generator.taskValue,
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
{
"name": "effekt",
"name": "@effekt-lang/effekt",
"author": "Jonathan Brachthäuser",
"version": "0.2.2",
"repository": {
"type": "git",
"url": "git+https://github.com/effekt-lang/effekt.git"
},
"description": "A language with effects and handlers",
"description": "A language with lexical effect handlers and lightweight effect polymorphism",
"main": "index.js",
"scripts": {},
"bin": {
"effekt": "bin/effekt",
"effekt.sh": "bin/effekt.sh"
},
"private": true,
"preferGlobal": true,
"license": "MIT",
"dependencies": {},
"files": [
"bin",
"libraries",
"licenses"
"licenses",
"README.md",
"LICENSE"
],
"bugs": {
"url": "https://github.com/effekt-lang/effekt/issues"
Expand Down
Loading
Loading