Release #36
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*"] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag to release, for example v1.0.1" | |
| required: true | |
| jobs: | |
| release: | |
| name: Publish npm packages and Homebrew formula | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run checks | |
| run: npm test | |
| - name: Verify package version matches tag | |
| env: | |
| RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} | |
| run: | | |
| version="$(node -p "require('./package.json').version")" | |
| desktop_version="$(node -p "require('./desktop/package.json').version")" | |
| desktop_dependency="$(node -p "require('./desktop/package.json').dependencies.kanbanqube")" | |
| if [ "v${version}" != "${RELEASE_TAG}" ]; then | |
| echo "package.json version ${version} does not match tag ${RELEASE_TAG}" >&2 | |
| exit 1 | |
| fi | |
| if [ "${desktop_version}" != "${version}" ]; then | |
| echo "desktop/package.json version ${desktop_version} does not match ${version}" >&2 | |
| exit 1 | |
| fi | |
| if [ "${desktop_dependency}" != "${version}" ]; then | |
| echo "kanbanqube-desktop depends on kanbanqube ${desktop_dependency}, expected ${version}" >&2 | |
| exit 1 | |
| fi | |
| echo "RELEASE_VERSION=${version}" >> "$GITHUB_ENV" | |
| - name: Setup npm publishing | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - name: Publish server package to npm | |
| run: npm publish --access public --provenance | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Run desktop package checks | |
| run: npm test --prefix desktop | |
| - name: Publish desktop package to npm | |
| run: npm publish ./desktop --access public --provenance | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create npm tarball | |
| run: | | |
| npm pack --json > pack.json | |
| filename="$(ruby -rjson -e 'puts JSON.parse(File.read("pack.json"))[0]["filename"]')" | |
| sha256="$(ruby -rdigest -e "puts Digest::SHA256.file('${filename}').hexdigest")" | |
| echo "PACKAGE_FILE=${filename}" >> "$GITHUB_ENV" | |
| echo "PACKAGE_SHA256=${sha256}" >> "$GITHUB_ENV" | |
| - name: Publish GitHub release | |
| uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 | |
| with: | |
| tag_name: v${{ env.RELEASE_VERSION }} | |
| name: KanbanQube v${{ env.RELEASE_VERSION }} | |
| files: ${{ env.PACKAGE_FILE }} | |
| - name: Update Homebrew formula on main | |
| run: | | |
| git fetch origin main | |
| git checkout main | |
| version="${{ env.RELEASE_VERSION }}" | |
| sha256="${{ env.PACKAGE_SHA256 }}" | |
| ruby -0pi -e "gsub(/version \"[^\"]+\"/, 'version \"' + '${version}' + '\"')" Formula/kanbanqube.rb | |
| ruby -0pi -e "gsub(/sha256 \"[^\"]+\"/, 'sha256 \"' + '${sha256}' + '\"')" Formula/kanbanqube.rb | |
| if git diff --quiet Formula/kanbanqube.rb; then | |
| echo "Formula already up to date" | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add Formula/kanbanqube.rb | |
| git commit -m "chore: update Homebrew formula for ${version}" | |
| git push origin HEAD:main | |
| desktop-cask: | |
| name: Build macOS desktop cask | |
| needs: release | |
| runs-on: macos-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Verify package version matches tag | |
| env: | |
| RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} | |
| run: | | |
| version="$(node -p "require('./desktop/package.json').version")" | |
| if [ "v${version}" != "${RELEASE_TAG}" ]; then | |
| echo "desktop/package.json version ${version} does not match tag ${RELEASE_TAG}" >&2 | |
| exit 1 | |
| fi | |
| echo "RELEASE_VERSION=${version}" >> "$GITHUB_ENV" | |
| - name: Install desktop dependencies | |
| run: npm install --prefix desktop | |
| - name: Package macOS app | |
| run: npm run package:mac --prefix desktop | |
| - name: Create Homebrew cask zips | |
| run: | | |
| ditto -c -k --sequesterRsrc --keepParent desktop/KanbanQube-darwin-arm64/KanbanQube.app KanbanQube-macOS-arm64.zip | |
| ditto -c -k --sequesterRsrc --keepParent desktop/KanbanQube-darwin-x64/KanbanQube.app KanbanQube-macOS-x64.zip | |
| - name: Publish desktop app release assets | |
| uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 | |
| with: | |
| tag_name: v${{ env.RELEASE_VERSION }} | |
| files: | | |
| KanbanQube-macOS-arm64.zip | |
| KanbanQube-macOS-x64.zip | |
| - name: Update Homebrew desktop cask on main | |
| run: | | |
| git fetch origin main | |
| git checkout main | |
| version="${{ env.RELEASE_VERSION }}" | |
| ruby -0pi -e "gsub(/version \"[^\"]+\"/, 'version \"' + '${version}' + '\"')" Casks/kanbanqube-desktop.rb | |
| if git diff --quiet Casks/kanbanqube-desktop.rb; then | |
| echo "Cask already up to date" | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add Casks/kanbanqube-desktop.rb | |
| git commit -m "chore: update Homebrew desktop cask for ${version}" | |
| git push origin HEAD:main |