fix naming inconsistency #49
This file contains 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: GH Release and NPM Publish | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'next' | |
paths: | |
- 'packages/**' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- package: 'logger' | |
nodeVersion: '20' | |
- package: 'seed' | |
nodeVersion: '20' | |
- package: 'utils' | |
nodeVersion: '20' | |
- package: 'nwcache' | |
nodeVersion: '20' | |
- package: 'controlflow' | |
nodeVersion: '20' | |
- package: 'publisher' | |
nodeVersion: '20' | |
- package: 'nocap' | |
nodeVersion: '20' | |
- package: 'nocap-websocket-adapter-default' | |
nodeVersion: '20' | |
- package: 'nocap-info-adapter-default' | |
nodeVersion: '20' | |
- package: 'nocap-dns-adapter-default' | |
nodeVersion: '20' | |
- package: 'nocap-geo-adapter-default' | |
nodeVersion: '20' | |
- package: 'nocap-ssl-adapter-default' | |
nodeVersion: '20' | |
- package: 'nocap-every-adapter-default' | |
nodeVersion: '20' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.nodeVersion }} | |
- name: Find Package | |
id: find_package | |
run: | | |
# Get the raw JSON output from 'yarn workspaces info --json' | |
WORKSPACES_JSON=$(yarn workspaces info --json) | |
# Extract only the JSON part using grep and sed | |
CLEANED_JSON=$(echo "$WORKSPACES_JSON" | grep -v 'yarn workspaces v' | grep -v 'Done in' | sed -n '/^{/,/^}/p') | |
# Process the JSON with jq to extract the package path | |
PKG_PATH=$(echo "$CLEANED_JSON" | jq -r '.["@nostrwatch/'"${{ matrix.package }}"'"].location') | |
# Check if the location is not null (valid JSON) | |
if [[ ! -z "$PKG_PATH" && "$PKG_PATH" != "null" ]]; then | |
echo "PKG_PATH: $PKG_PATH" | |
else | |
echo "Error: Unable to extract valid JSON data." | |
fi | |
echo "the_path=$PKG_PATH" >> "$GITHUB_OUTPUT" | |
- name: Install Package | |
id: install_package | |
run: | | |
cd "${{ steps.find_package.outputs.the_path }}" | |
yarn install | |
- name: Publish Package | |
id: publish | |
uses: JS-DevTools/npm-publish@v3 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
package: ${{ steps.find_package.outputs.the_path }}/package.json | |
strategy: all | |
access: public | |
- name: Set Meta | |
id: meta | |
run: | | |
RELEASE_SLUG="${{ matrix.package }}@v${{ steps.publish.outputs.version }}" | |
echo "RELEASE SLUG: $RELEASE_SLUG" >> .fml | |
echo "release_slug=$RELEASE_SLUG" >> "$GITHUB_OUTPUT" | |
- name: Archive Subdirectory | |
id: archive | |
run: | | |
zip -r "${{ steps.meta.outputs.release_slug}}.zip" "${{ steps.find_package.outputs.the_path }}" | |
- if: steps.publish.outputs.type != 'none' && steps.publish.outputs.dry_run != true | |
id: create_release | |
uses: actions/create-release@latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.meta.outputs.release_slug }} | |
release_name: ${{ steps.meta.outputs.release_slug }} | |
body: "" | |
draft: false | |
prerelease: true | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./${{ steps.meta.outputs.release_slug}}.zip | |
asset_name: ${{ steps.meta.outputs.release_slug}}.zip | |
asset_content_type: application/zip |