Release #23
Workflow file for this run
This file contains hidden or 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
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v[0-9]+.[0-9]+.[0-9]+' | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to build (e.g. v1.1.0)' | |
| required: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Run tests | |
| run: ./gradlew test | |
| build-linux: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: graalvm/setup-graalvm@v1 | |
| with: | |
| java-version: '21' | |
| distribution: 'graalvm-community' | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Verify version matches tag | |
| # Only enforce on real tag pushes; workflow_dispatch is used for rc tags | |
| # (e.g. v1.2.0-rc1) which intentionally won't match the build.gradle.kts version. | |
| if: github.event_name == 'push' | |
| run: | | |
| GRADLE_VER=$(grep '^version = ' build.gradle.kts | sed 's/version = "\(.*\)"/\1/') | |
| TAG_VER=${GITHUB_REF_NAME#v} | |
| if [ "${GRADLE_VER}" != "${TAG_VER}" ]; then | |
| echo "Tag ${GITHUB_REF_NAME} does not match build.gradle.kts version ${GRADLE_VER}" | |
| exit 1 | |
| fi | |
| - name: Build native image | |
| run: ./gradlew nativeCompile | |
| - name: Smoke test | |
| run: | | |
| ./build/native/nativeCompile/localdevstack --service go --database postgres --output /tmp/s1 --name t | |
| test -f /tmp/s1/service/main.go && test -f /tmp/s1/docker-compose.yml | |
| mkdir /tmp/ex && echo 'module test' > /tmp/ex/go.mod | |
| ./build/native/nativeCompile/localdevstack --existing-dir /tmp/ex --database postgres | |
| test -f /tmp/ex/Dockerfile.dev && test -f /tmp/ex/docker-compose.yml | |
| - name: Package artifact | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| cp build/native/nativeCompile/localdevstack localdevstack-linux-x64 | |
| tar czf localdevstack-${VERSION}-linux-x64.tar.gz localdevstack-linux-x64 | |
| sha256sum localdevstack-${VERSION}-linux-x64.tar.gz > localdevstack-${VERSION}-linux-x64.tar.gz.sha256 | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-x64 | |
| path: localdevstack-*-linux-x64.tar.gz* | |
| # build-macos-x64 was removed when GitHub retired the macos-13 runner image | |
| # (only the latest two macOS versions stay supported, and no free Intel macOS | |
| # runner exists in its place). Apple stopped selling Intel Macs in 2023, so | |
| # arm64-only macOS coverage is the trade-off; Intel mac users build from | |
| # source via `brew install --build-from-source localdevstack`. | |
| build-macos-arm64: | |
| needs: test | |
| runs-on: macos-14 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: graalvm/setup-graalvm@v1 | |
| with: | |
| java-version: '21' | |
| distribution: 'graalvm-community' | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build native image | |
| run: ./gradlew nativeCompile | |
| # No smoke test on macOS — see build-macos-x64 above for rationale. | |
| - name: Package artifact | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| cp build/native/nativeCompile/localdevstack localdevstack-macos-arm64 | |
| tar czf localdevstack-${VERSION}-macos-arm64.tar.gz localdevstack-macos-arm64 | |
| shasum -a 256 localdevstack-${VERSION}-macos-arm64.tar.gz > localdevstack-${VERSION}-macos-arm64.tar.gz.sha256 | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-arm64 | |
| path: localdevstack-*-macos-arm64.tar.gz* | |
| build-windows: | |
| needs: test | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: graalvm/setup-graalvm@v1 | |
| with: | |
| java-version: '21' | |
| distribution: 'graalvm-community' | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| # native-image on Windows shells out to cl.exe / link.exe and needs the | |
| # MSVC developer environment loaded. setup-graalvm's `native-image-msvc` | |
| # flag is unreliable on windows-latest (still fails with "vcvarsall.bat | |
| # not found"). ilammy/msvc-dev-cmd directly invokes vcvarsall.bat and | |
| # exports the env vars to the rest of the job, which works consistently. | |
| - uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - name: Build native image | |
| run: ./gradlew nativeCompile | |
| - name: Package artifact | |
| shell: pwsh | |
| run: | | |
| $VERSION = $env:GITHUB_REF_NAME -replace '^v', '' | |
| Copy-Item build/native/nativeCompile/localdevstack.exe localdevstack-windows-x64.exe | |
| Compress-Archive localdevstack-windows-x64.exe "localdevstack-${VERSION}-windows-x64.zip" | |
| $hash = (Get-FileHash "localdevstack-${VERSION}-windows-x64.zip" -Algorithm SHA256).Hash.ToLower() | |
| "${hash} localdevstack-${VERSION}-windows-x64.zip" | Out-File -Encoding utf8 "localdevstack-${VERSION}-windows-x64.zip.sha256" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-x64 | |
| path: localdevstack-*-windows-x64.zip* | |
| publish: | |
| needs: [build-linux, build-macos-arm64, build-windows] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| merge-multiple: true | |
| path: dist/ | |
| - name: Publish to distribution repo | |
| env: | |
| DIST_TOKEN: ${{ secrets.DIST_TOKEN }} | |
| GH_TOKEN: ${{ secrets.DIST_TOKEN }} | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| # Create release in the public distribution repo | |
| gh release create "$GITHUB_REF_NAME" \ | |
| --repo krishgok/localdevstack \ | |
| --title "LocalDevelopmentStack v${VERSION}" \ | |
| --generate-notes \ | |
| dist/* | |
| # Update Homebrew formula (arm64 macOS + linux-x64; Intel macOS was | |
| # dropped when the macos-13 runner was retired — see build job above). | |
| SHA_ARM64=$(cat dist/localdevstack-${VERSION}-macos-arm64.tar.gz.sha256 | awk '{print $1}') | |
| SHA_LINUX=$(cat dist/localdevstack-${VERSION}-linux-x64.tar.gz.sha256 | awk '{print $1}') | |
| git clone https://x-access-token:${DIST_TOKEN}@github.com/krishgok/localdevstack.git dist-repo/ | |
| cd dist-repo | |
| sed -i "s/version \".*\"/version \"${VERSION}\"/" Formula/localdevstack.rb | |
| sed -i "s|url \".*macos-arm64.*\"|url \"https://github.com/krishgok/localdevstack/releases/download/v${VERSION}/localdevstack-${VERSION}-macos-arm64.tar.gz\"|" Formula/localdevstack.rb | |
| sed -i "s/sha256 \".*\" # arm64/sha256 \"${SHA_ARM64}\" # arm64/" Formula/localdevstack.rb | |
| sed -i "s|url \".*linux-x64.*\"|url \"https://github.com/krishgok/localdevstack/releases/download/v${VERSION}/localdevstack-${VERSION}-linux-x64.tar.gz\"|" Formula/localdevstack.rb | |
| sed -i "s/sha256 \".*\" # linux-x64/sha256 \"${SHA_LINUX}\" # linux-x64/" Formula/localdevstack.rb | |
| # Update Scoop manifest | |
| SHA_WIN=$(cat ../dist/localdevstack-${VERSION}-windows-x64.zip.sha256 | awk '{print $1}') | |
| python3 -c " | |
| import json | |
| with open('bucket/localdevstack.json') as f: m = json.load(f) | |
| m['version'] = '${VERSION}' | |
| m['architecture']['64bit']['url'] = 'https://github.com/krishgok/localdevstack/releases/download/v${VERSION}/localdevstack-${VERSION}-windows-x64.zip' | |
| m['architecture']['64bit']['hash'] = '${SHA_WIN}' | |
| with open('bucket/localdevstack.json', 'w') as f: json.dump(m, f, indent=2) | |
| print('Updated Scoop manifest') | |
| " | |
| git config user.email "release-bot@localdevstack.io" | |
| git config user.name "Release Bot" | |
| git add Formula/localdevstack.rb bucket/localdevstack.json | |
| git commit -m "localdevstack v${VERSION}" | |
| git push |