Skip to content

Commit 4091088

Browse files
authored
Release tweaks (#690)
* Safer injection of ref. * Remove defunct docker cache. * Run dev releases in dockerhub environment. * Ensure we only publish dev versions on docker-dev actions.
1 parent bbbc231 commit 4091088

4 files changed

Lines changed: 29 additions & 9 deletions

File tree

.github/workflows/docker-dev.yaml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
release-docker-image:
1414
name: Build and Release powersync-service Docker Image
1515
runs-on: ubuntu-latest
16+
environment: dockerhub
1617
steps:
1718
- name: Checkout
1819
uses: actions/checkout@v5
@@ -51,11 +52,31 @@ jobs:
5152
pnpm changeset status
5253
pnpm changeset version --snapshot dev
5354
54-
# This uses the service's package.json version for the Docker Image tag
55-
# The changeset command above should change this to a dev package
56-
- name: Get Service Version from package.json
55+
# This uses the service's package.json version for the Docker Image tag.
56+
# The changeset command above must change this to a dev package version.
57+
- name: Get dev service version from package.json
5758
id: get_version
58-
run: echo "SERVICE_VERSION=$(node -p "require('./service/package.json').version")" >> $GITHUB_OUTPUT
59+
run: |
60+
version="$(node -p "require('./service/package.json').version")"
61+
62+
node -e '
63+
const semver = require("semver");
64+
const version = process.argv[1];
65+
const parsed = semver.parse(version);
66+
67+
if (!parsed) {
68+
console.error("Service version " + version + " is not a valid semver version.");
69+
process.exit(1);
70+
}
71+
72+
const prerelease = parsed.prerelease.join(".");
73+
if (!/^dev(?:[.-]|$)/.test(prerelease)) {
74+
console.error("Service version " + version + " is not a dev snapshot version.");
75+
process.exit(1);
76+
}
77+
' "$version"
78+
79+
echo "SERVICE_VERSION=$version" >> "$GITHUB_OUTPUT"
5980
6081
- name: Extract metadata for the image
6182
uses: docker/metadata-action@v5

.github/workflows/docker-next.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ jobs:
2424
- name: Validate release tag
2525
id: version
2626
run: |
27-
if [ "${{ github.ref_type }}" != "tag" ]; then
27+
if [ "$GITHUB_REF_TYPE" != "tag" ]; then
2828
echo "This workflow must be run against a git tag, e.g. gh workflow run docker-next --ref v1.21.0" >&2
2929
exit 1
3030
fi
3131
3232
version="$(node -p "require('./service/package.json').version")"
33-
tag="${{ github.ref_name }}"
33+
tag="$GITHUB_REF_NAME"
3434
3535
if [ "$tag" != "v$version" ]; then
3636
echo "Git tag $tag does not match service package version $version" >&2

.github/workflows/docker-stable.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ jobs:
2424
- name: Validate release tag
2525
id: version
2626
run: |
27-
if [ "${{ github.ref_type }}" != "tag" ]; then
27+
if [ "$GITHUB_REF_TYPE" != "tag" ]; then
2828
echo "This workflow must be run against a git tag, e.g. gh workflow run docker-stable --ref v1.21.0" >&2
2929
exit 1
3030
fi
3131
3232
version="$(node -p "require('./service/package.json').version")"
33-
tag="${{ github.ref_name }}"
33+
tag="$GITHUB_REF_NAME"
3434
3535
if [ "$tag" != "v$version" ]; then
3636
echo "Git tag $tag does not match service package version $version" >&2

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ jobs:
6060
- name: Test Build Docker Image
6161
uses: docker/build-push-action@v5
6262
with:
63-
cache-from: type=registry,ref=stevenontong/${{vars.DOCKER_REGISTRY}}:cache
6463
context: .
6564
platforms: linux/amd64
6665
push: false

0 commit comments

Comments
 (0)