Skip to content

Publish

Publish #6

Workflow file for this run

name: Publish
on:
workflow_dispatch:
inputs:
release_type:
description: Release type
type: choice
required: true
default: patch
options:
- patch
- minor
- major
- prepatch
- preminor
- premajor
- prerelease
concurrency:
group: publish-${{ github.workflow }}
cancel-in-progress: false
jobs:
publish:
name: Build and publish to npm
# Builds the native macOS tool binary, so it must run on macOS.
# The package declares swift-tools-version 6.2, which requires Xcode 26+.
runs-on: macos-26
permissions:
# Required for npm trusted publishing (OIDC) and provenance.
id-token: write
# Required to push the version bump commit/tag and create the release.
contents: write
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
# The default token lets gh create the release and push the bump
# commit/tag. Note: commits pushed with GITHUB_TOKEN do NOT trigger
# other workflows (e.g. the Swift CI), by GitHub's design.
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- name: Update npm
# Trusted publishing requires npm >= 11.5.1.
run: npm install -g npm@latest
- name: Configure git
run: |
git config user.name "expo-bot"
git config user.email "expo-bot@users.noreply.github.com"
- name: Bump version
id: bump
# Only edit package.json here; the commit, tag and release are created
# at the end so a failed build/publish leaves the branch untouched.
run: |
version=$(npm version "${{ inputs.release_type }}" --no-git-tag-version)
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Bumping to $version"
- name: Select Xcode
# Pin to an Xcode that ships Swift 6.2 (required by Package.swift).
run: sudo xcode-select -switch /Applications/Xcode_26.4.1.app
- name: Cache SwiftPM build
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: apple/.build
key: spm-${{ runner.os }}-${{ hashFiles('apple/Package.resolved') }}
restore-keys: |
spm-${{ runner.os }}-
- name: Resolve dependencies
run: swift package resolve
working-directory: apple
- name: Build release tool
# Runs apple/build.js: builds the release plugin binary,
# copies it to apple/ExpoModulesMacros-tool, and strips it.
run: npm run build
- name: Publish
# Authentication is handled via OIDC trusted publishing — no token needed.
# npm generates provenance automatically when publishing via OIDC.
run: npm publish --access public
# Everything below only runs once the publish above has succeeded.
- name: Commit, tag and push
run: |
version="${{ steps.bump.outputs.version }}"
git commit -am "Release $version"
# Use an annotated tag so `git push --follow-tags` actually pushes it
# (--follow-tags ignores lightweight tags).
git tag -a "$version" -m "Release $version"
git push --follow-tags origin HEAD
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Tag prerelease versions (those containing a hyphen) as prereleases.
run: |
version="${{ steps.bump.outputs.version }}"
prerelease=""
case "$version" in
*-*) prerelease="--prerelease" ;;
esac
gh release create "$version" \
--title "$version" \
--generate-notes \
$prerelease