Skip to content

Commit 2696792

Browse files
committed
Merge branch 'main' into function-invocation-simplification
2 parents 2072c59 + 0de6d8f commit 2696792

8 files changed

Lines changed: 205 additions & 16 deletions

File tree

.github/workflows/publish-api.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish API
2+
3+
on:
4+
push:
5+
tags:
6+
- "api-v*"
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
publish:
13+
name: Publish liquidjava-api to Maven Central
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Ensure tag is on main
23+
run: |
24+
git fetch origin main
25+
TAG_COMMIT="$(git rev-list -n 1 "$GITHUB_REF_NAME")"
26+
git merge-base --is-ancestor "$TAG_COMMIT" origin/main
27+
28+
- name: Set up JDK 20
29+
uses: actions/setup-java@v4
30+
with:
31+
distribution: temurin
32+
java-version: "20"
33+
cache: maven
34+
server-id: central
35+
server-username: CENTRAL_USERNAME
36+
server-password: CENTRAL_PASSWORD
37+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
38+
gpg-passphrase: GPG_PASSPHRASE
39+
40+
- name: Publish API
41+
run: ./mvnw -f liquidjava-api/pom.xml -B --fail-fast -Dgpg.skip=false -Dmaven.deploy.skip=false clean deploy
42+
env:
43+
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
44+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
45+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish verifier
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
publish:
13+
name: Publish liquidjava-verifier to Maven Central
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Ensure tag is on main
23+
run: |
24+
git fetch origin main
25+
TAG_COMMIT="$(git rev-list -n 1 "$GITHUB_REF_NAME")"
26+
git merge-base --is-ancestor "$TAG_COMMIT" origin/main
27+
28+
- name: Set up JDK 20
29+
uses: actions/setup-java@v4
30+
with:
31+
distribution: temurin
32+
java-version: "20"
33+
cache: maven
34+
server-id: central
35+
server-username: CENTRAL_USERNAME
36+
server-password: CENTRAL_PASSWORD
37+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
38+
gpg-passphrase: GPG_PASSPHRASE
39+
40+
- name: Publish verifier
41+
run: ./mvnw -f liquidjava-verifier/pom.xml -B --fail-fast -Dgpg.skip=false -Dmaven.deploy.skip=false clean deploy
42+
env:
43+
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
44+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
45+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"java.configuration.updateBuildConfiguration": "automatic"
2+
"java.configuration.updateBuildConfiguration": "automatic",
3+
"java.autobuild.enabled": false
34
}

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,33 @@ Verify a single file from the CLI:
2828

2929
Code formatting runs automatically via `formatter-maven-plugin` during the `validate` phase.
3030

31+
## Release
32+
33+
Releases are published through GitHub Actions when release tags are pushed to
34+
`main`:
35+
36+
- `v*` tags publish `liquidjava-verifier` through the `publish-verifier`
37+
workflow.
38+
- `api-v*` tags publish `liquidjava-api` through the `publish-api` workflow.
39+
40+
Use `release.sh` from the repository root to publish a release.
41+
The script automatically verifies the build and tests, bumps the module version, commits the version change, creates the matching tag, and pushes them to `main`.
42+
43+
```bash
44+
./release.sh verifier # publishes liquidjava-verifier
45+
./release.sh api # publishes liquidjava-api
46+
```
47+
48+
You can also pass the release version explicitly:
49+
50+
```bash
51+
./release.sh verifier 1.2.3
52+
./release.sh api 1.2.3
53+
```
54+
55+
Run releases from a clean `main` branch. Once the tag is pushed, the matching
56+
GitHub Actions workflow publishes the module to Maven Central.
57+
3158
## Adding test cases
3259

3360
Tests live under `liquidjava-example/src/main/java/testSuite/` and are auto-discovered:

liquidjava-api/pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
<configuration>
143143
<publishingServerId>central</publishingServerId>
144144
<skipPublishing>${maven.deploy.skip}</skipPublishing>
145-
<!-- <autoPublish>true</autoPublish> -->
145+
<autoPublish>true</autoPublish>
146+
<waitUntil>published</waitUntil>
146147
</configuration>
147148
</plugin>
148149
</plugins>
@@ -163,4 +164,4 @@
163164
<gpg.skip>true</gpg.skip>
164165
<maven.deploy.skip>true</maven.deploy.skip>
165166
</properties>
166-
</project>
167+
</project>

liquidjava-verifier/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@
213213
<configuration>
214214
<publishingServerId>central</publishingServerId>
215215
<skipPublishing>${maven.deploy.skip}</skipPublishing>
216-
<!-- <autoPublish>true</autoPublish> -->
216+
<autoPublish>true</autoPublish>
217+
<waitUntil>published</waitUntil>
217218
</configuration>
218219
</plugin>
219220
</plugins>

liquidjava-verifier/src/main/java/liquidjava/rj_language/opt/VariablePropagation.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ public class VariablePropagation {
2424
*/
2525
public static ValDerivationNode propagate(Expression exp, ValDerivationNode previousOrigin) {
2626
Map<String, Expression> substitutions = VariableResolver.resolve(exp);
27-
Map<String, Expression> constantSubstitutions = new HashMap<>();
28-
Map<String, Expression> expressionSubstitutions = new HashMap<>();
27+
Map<String, Expression> directSubstitutions = new HashMap<>(); // var == literal or var == var
28+
Map<String, Expression> expressionSubstitutions = new HashMap<>(); // var == expression
2929
for (Map.Entry<String, Expression> entry : substitutions.entrySet()) {
3030
Expression value = entry.getValue();
3131
if (value.isLiteral() || value instanceof Var) {
32-
constantSubstitutions.put(entry.getKey(), value);
32+
directSubstitutions.put(entry.getKey(), value);
3333
} else {
3434
expressionSubstitutions.put(entry.getKey(), value);
3535
}
@@ -40,8 +40,8 @@ public static ValDerivationNode propagate(Expression exp, ValDerivationNode prev
4040
if (previousOrigin != null) {
4141
extractVarOrigins(previousOrigin, varOrigins);
4242
}
43-
Map<String, Expression> activeSubstitutions = constantSubstitutions.isEmpty() ? expressionSubstitutions
44-
: constantSubstitutions;
43+
Map<String, Expression> activeSubstitutions = directSubstitutions.isEmpty() ? expressionSubstitutions
44+
: directSubstitutions;
4545
return propagateRecursive(exp, activeSubstitutions, varOrigins);
4646
}
4747

release.sh

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,89 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

3-
if [ -z "$1" ]; then
4-
echo "Usage: $0 <api|verifier>"
3+
set -euo pipefail
4+
5+
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
6+
echo "Usage: $0 <api|verifier> [version]"
57
exit 1
68
fi
79

810
MODULE=$1
11+
VERSION=${2:-}
912

1013
if [ "$MODULE" != "api" ] && [ "$MODULE" != "verifier" ]; then
1114
echo "Invalid module: $MODULE"
12-
echo "Usage: $0 <api|verifier>"
15+
echo "Usage: $0 <api|verifier> [version]"
1316
exit 1
1417
fi
1518

1619
MODULE_DIR="liquidjava-$MODULE"
20+
POM="$MODULE_DIR/pom.xml"
21+
22+
if [ -z "$VERSION" ]; then
23+
CURRENT_VERSION=$(perl -0ne "print \$1 if m#<artifactId>\\Q$MODULE_DIR\\E</artifactId>\\s*<version>([^<]+)</version>#" "$POM")
24+
25+
if [ -z "$CURRENT_VERSION" ]; then
26+
echo "Could not read current version from $POM"
27+
exit 1
28+
fi
29+
30+
if ! [[ "$CURRENT_VERSION" =~ ^[0-9]+(\.[0-9]+){1,2}$ ]]; then
31+
echo "Cannot automatically bump non-numeric version: $CURRENT_VERSION"
32+
echo "Pass the release version explicitly."
33+
exit 1
34+
fi
35+
36+
IFS=. read -ra VERSION_PARTS <<<"$CURRENT_VERSION"
37+
LAST_INDEX=$((${#VERSION_PARTS[@]} - 1))
38+
VERSION_PARTS[$LAST_INDEX]=$((${VERSION_PARTS[$LAST_INDEX]} + 1))
39+
VERSION=$(IFS=.; echo "${VERSION_PARTS[*]}")
40+
41+
echo "Bumping $MODULE_DIR from $CURRENT_VERSION to $VERSION"
42+
fi
43+
44+
if ! [[ "$VERSION" =~ ^[0-9]+(\.[0-9]+){1,2}(-[A-Za-z0-9.-]+)?$ ]]; then
45+
echo "Invalid version: $VERSION"
46+
echo "Expected format: 1.2.3"
47+
exit 1
48+
fi
49+
50+
if [ "$MODULE" = "api" ]; then
51+
TAG="api-v$VERSION"
52+
else
53+
TAG="v$VERSION"
54+
fi
55+
56+
CURRENT_BRANCH=$(git branch --show-current)
57+
if [ "$CURRENT_BRANCH" != "main" ]; then
58+
echo "Release must be run from main. Current branch: $CURRENT_BRANCH"
59+
exit 1
60+
fi
61+
62+
if [ -n "$(git status --porcelain)" ]; then
63+
echo "Worktree must be clean before releasing."
64+
git status --short
65+
exit 1
66+
fi
67+
68+
if git rev-parse "$TAG" >/dev/null 2>&1; then
69+
echo "Tag already exists: $TAG"
70+
exit 1
71+
fi
72+
73+
./mvnw -f "$POM" -B --fail-fast -Dgpg.skip=true -Dmaven.deploy.skip=true clean verify
74+
75+
perl -0pi -e "s#(<artifactId>$MODULE_DIR</artifactId>\\s*<version>)[^<]+(</version>)#\${1}$VERSION\${2}#" "$POM"
76+
77+
if git diff --quiet -- "$POM"; then
78+
echo "$POM is already at version $VERSION"
79+
exit 1
80+
fi
81+
82+
git add "$POM"
83+
git commit -m "Release $MODULE_DIR $VERSION"
84+
git tag "$TAG"
85+
86+
git push origin main
87+
git push origin "$TAG"
1788

18-
cd "$MODULE_DIR"
19-
mvn -Dgpg.skip=false -Dmaven.deploy.skip=false clean deploy
20-
cd ..
89+
echo "Created and pushed $TAG. GitHub Actions will publish $MODULE_DIR to Maven Central."

0 commit comments

Comments
 (0)