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 varlock CLI binaries | |
| # normal CI release workflow handles publishing multiple packages from the monorepo | |
| # this workflow triggered by a release `[email protected]` | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version (ex: "1.2.3")' | |
| required: true | |
| type: string | |
| release: | |
| types: [published] | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| debug: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: print github context | |
| env: | |
| GITHUB_CONTEXT: ${{ toJson(github) }} | |
| run: | | |
| echo "$GITHUB_CONTEXT" | |
| release-binaries: | |
| # was using github.ref.tag_name, but it seems that when publishing multiple tags at once, it was behaving weirdly | |
| if: github.event_name == 'workflow_dispatch' || startsWith(github.ref_name, 'varlock@') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| run_install: false | |
| - name: Use Node.js 22.x | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: "22.x" | |
| cache: 'pnpm' | |
| - name: Install node deps | |
| run: pnpm i | |
| - name: Enable turborepo build cache | |
| uses: rharkor/[email protected] | |
| # ------------------------------------------------------------ | |
| - name: get version from release tag | |
| if: ${{ github.event_name == 'release' }} | |
| run: | | |
| # get the full release tag name - ex: [email protected] | |
| echo "RELEASE_TAG=${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
| # get the version only from the tag - ex: 1.2.3 | |
| echo "RELEASE_VERSION=${GITHUB_REF_NAME#varlock@}" >> $GITHUB_ENV | |
| - name: use manual version from input | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| run: | | |
| echo "RELEASE_TAG=varlock@${{ inputs.version }}" >> $GITHUB_ENV | |
| echo "RELEASE_VERSION=${{ inputs.version }}" >> $GITHUB_ENV | |
| # necessary to bundle macos binaries (from linux) | |
| - name: install ldid | |
| uses: MOZGIII/install-ldid-action@v1 | |
| with: | |
| tag: v2.1.5-procursus7 | |
| # necessary for cross-arch linux binaries | |
| - name: Install qemu-user-binfmt | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install --assume-yes qemu-user-binfmt | |
| - name: build libs | |
| run: pnpm build:libs | |
| env: | |
| BUILD_TYPE: release | |
| - name: build SEA dist files (CJS, no deps) | |
| run: pnpm run --filter varlock build:sea | |
| env: | |
| BUILD_TYPE: release | |
| - name: Restore pkg Node.js base binaries | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ~/.pkg-cache | |
| key: pkg-nodejs-base-binaries-node-22 | |
| - name: build varlock SEA binaries (pkg) | |
| run: PKG_CACHE_PATH=~/.pkg-cache node scripts/build-binaries.js | |
| - name: Cache pkg Node.js base binaries | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: ~/.pkg-cache | |
| key: pkg-nodejs-base-binaries-node-22 | |
| - name: add binaries to GH release | |
| env: | |
| # default token works to update release on this repo | |
| GH_TOKEN: ${{ github.token }} | |
| working-directory: packages/varlock/dist-sea | |
| run: gh release upload ${{ env.RELEASE_TAG }} *.{tar.gz,zip} checksums.txt --clobber | |
| # UPDATE HOMEBREW FORMULA --- | |
| - name: checkout homebrew tap repo | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: dmno-dev/homebrew-tap | |
| # need a different token to update a different repo | |
| token: ${{ secrets.HOMEBREW_REPO_GITHUB_ACCESS_TOKEN }} | |
| path: homebrew-tap | |
| clean: false | |
| - name: update homebrew formula | |
| run: node scripts/update-homebrew-formula.js | |
| - name: commit and push homebrew tap update | |
| run: | | |
| cd homebrew-tap | |
| git config --global user.name 'theoephraim' | |
| git config --global user.email '[email protected]' | |
| git add . | |
| git commit -m "varlock@${{ env.RELEASE_VERSION }}" | |
| git tag "varlock@${{ env.RELEASE_VERSION }}" | |
| git push origin HEAD --tags | |
| release-docker: | |
| needs: release-binaries | |
| if: github.event_name == 'workflow_dispatch' || startsWith(github.ref_name, 'varlock@') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: get version from release tag | |
| if: ${{ github.event_name == 'release' }} | |
| run: | | |
| # get the version only from the tag - ex: 1.2.3 | |
| echo "RELEASE_VERSION=${GITHUB_REF_NAME#varlock@}" >> $GITHUB_ENV | |
| - name: use manual version from input | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| run: | | |
| echo "RELEASE_VERSION=${{ inputs.version }}" >> $GITHUB_ENV | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: | | |
| ghcr.io/dmno-dev/varlock:${{ env.RELEASE_VERSION }} | |
| ghcr.io/dmno-dev/varlock:latest | |
| build-args: | | |
| VARLOCK_VERSION=${{ env.RELEASE_VERSION }} | |
| VARLOCK_ARCH=linux-x64 | |
| platforms: linux/amd64,linux/arm64 |