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 7 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
68 changes: 68 additions & 0 deletions .github/workflows/autorelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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
inputs:
patch_version:
description: 'Patch version number (default is 0)'
required: false
default: '0'

jobs:
calculate-version-and-tag:
name: Calculate Version and Create Tag
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Calculate new version
id: set-version
run: |
MAJOR=0
YEAR=$(date +%y)
WEEK=$(date +%W)
WEEK_PADDED=$(printf "%02d" $WEEK)
PATCH="${{ github.event.inputs.patch_version }}"
if [[ -z "$PATCH" ]]; then
PATCH="0"
fi
VERSION="${MAJOR}.${YEAR}.${WEEK_PADDED}.${PATCH}"
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT

- name: Update version in build.sbt
run: |
sed -i 's/lazy val effektVersion = ".*"/lazy val effektVersion = "${{ steps.set-version.outputs.VERSION }}"/' build.sbt

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'zulu'
cache: 'sbt'

- name: Set up NodeJS
uses: actions/setup-node@v4
with:
node-version: '12.x'

- name: Update NPM and MVN versions 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 build.sbt
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 }}
104 changes: 80 additions & 24 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
# 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

jobs:
build-jar:
name: Build Effekt compiler and run tests
name: Build the Effekt compiler and run tests
runs-on: ubuntu-latest
steps:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
version: ${{ steps.get_version.outputs.VERSION }}

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

- name: Set up JDK 11
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 11
java-version: '11'
distribution: 'temurin'

- name: Set up NodeJS
uses: actions/setup-node@v1
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '12.x'

Expand All @@ -39,21 +49,35 @@ jobs:
- name: Install Chez Scheme
run: sudo apt-get install chezscheme

- 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: Run tests and 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@v3
with:
name: effekt
path: bin/effekt

- name: Upload the npm package
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v3
with:
name: effekt-npm-package
path: effekt.tgz
Expand All @@ -63,35 +87,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@v3
with:
name: effekt
path: distribution/

- name: Download npm package
uses: actions/download-artifact@v1
uses: actions/download-artifact@v3
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: ${{ steps.generate_release_notes.outputs.name }}
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 +138,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 +146,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@v3
with:
name: effekt-npm-package

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'

- name: Publish to NPM as @effekt-lang/effekt
run: npm publish effekt.tgz --access public --scope @effekt-lang
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Loading