Skip to content

Release

Release #26

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g. v1.0.0) — must already exist'
required: true
type: string
concurrency:
group: release
cancel-in-progress: false
jobs:
build-library:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup
uses: ./.github/actions/setup
- name: Build package
run: yarn prepare
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: lib
path: lib/
retention-days: 1
publish-npm:
runs-on: ubuntu-latest
needs: build-library
permissions:
contents: write
id-token: write
environment:
name: npm
url: https://www.npmjs.com/package/react-native-media-toolkit
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup
uses: ./.github/actions/setup
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: lib
path: lib/
- name: Get version from tag
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
else
TAG="${{ github.ref_name }}"
fi
VERSION="${TAG#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
- name: Verify package version matches tag
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
TAG_VERSION="${{ steps.version.outputs.version }}"
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
echo "❌ package.json version ($PKG_VERSION) does not match tag ($TAG_VERSION)"
exit 1
fi
echo "✅ Version match: $PKG_VERSION"
- name: Setup Node.js for npm publish
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: .nvmrc
registry-url: 'https://registry.npmjs.org'
- name: Publish to npm
run: yarn npm publish --access public
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: 'v${{ steps.version.outputs.version }}'
generate_release_notes: true
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Summary
run: |
echo "## 🚀 Released v${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- 📦 [npm package](https://www.npmjs.com/package/react-native-media-toolkit/v/${{ steps.version.outputs.version }})" >> $GITHUB_STEP_SUMMARY
echo "- 🏷️ [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.tag }})" >> $GITHUB_STEP_SUMMARY