chore(release): v0.4.11 #16
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*.*.*" | |
| permissions: | |
| contents: write | |
| id-token: write | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup build environment | |
| uses: ./.github/actions/setup-build-env | |
| with: | |
| registry-url: https://registry.npmjs.org | |
| - name: Validate release version | |
| env: | |
| TAG_NAME: ${{ github.ref_name }} | |
| run: | | |
| node - <<'NODE' | |
| const fs = require("node:fs"); | |
| const tag = process.env.TAG_NAME.replace(/^v/, ""); | |
| const files = [ | |
| "packages/icons/package.json", | |
| "packages/icons-react/package.json" | |
| ]; | |
| for (const file of files) { | |
| const pkg = JSON.parse(fs.readFileSync(file, "utf8")); | |
| if (pkg.version !== tag) { | |
| throw new Error(`${file} version ${pkg.version} does not match ${process.env.TAG_NAME}`); | |
| } | |
| } | |
| NODE | |
| - name: Lint | |
| run: bun run lint | |
| - name: Build release artifacts | |
| run: bun run release:build | |
| - name: Verify generated release artifacts are up to date | |
| run: | | |
| git diff --exit-code -- tags.json packages/icons/meta.json | |
| node - <<'NODE' | |
| const fs = require("node:fs"); | |
| const path = require("node:path"); | |
| const pkg = JSON.parse(fs.readFileSync("packages/icons/package.json", "utf8")); | |
| const missing = []; | |
| for (const entry of pkg.files) { | |
| if (entry.startsWith("!")) continue; | |
| if (entry === "icons/*.svg" || entry === "icons-solid/*.svg") { | |
| const dir = path.join("packages/icons", entry.split("/")[0]); | |
| const hasSvg = fs.existsSync(dir) && fs.readdirSync(dir).some((file) => file.endsWith(".svg")); | |
| if (!hasSvg) missing.push(entry); | |
| continue; | |
| } | |
| if (!fs.existsSync(path.join("packages/icons", entry))) { | |
| missing.push(entry); | |
| } | |
| } | |
| if (missing.length > 0) { | |
| throw new Error(`Missing @mynaui/icons package files:\n${missing.join("\n")}`); | |
| } | |
| NODE | |
| - name: Publish packages | |
| run: | | |
| publish_package() { | |
| package_dir="$1" | |
| package_name=$(node -p "require('./${package_dir}/package.json').name") | |
| package_version=$(node -p "require('./${package_dir}/package.json').version") | |
| if npm view "${package_name}@${package_version}" version >/dev/null 2>&1; then | |
| echo "${package_name}@${package_version} is already published; skipping." | |
| else | |
| npm publish --workspace "./${package_dir}" --access public | |
| fi | |
| } | |
| publish_package packages/icons | |
| publish_package packages/icons-react | |
| - name: Create GitHub release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| TAG_NAME: ${{ github.ref_name }} | |
| run: | | |
| if gh release view "$TAG_NAME" >/dev/null 2>&1; then | |
| echo "GitHub release $TAG_NAME already exists; skipping." | |
| else | |
| gh release create "$TAG_NAME" --title "$TAG_NAME" --generate-notes --verify-tag | |
| fi |