Test pre-release attempt 2 #39
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: Publish | |
| on: | |
| release: | |
| types: [published, prereleased] | |
| permissions: | |
| contents: read | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: publish-${{ github.event.release.tag_name }} | |
| cancel-in-progress: true | |
| environment: | |
| name: npm | |
| url: ${{ github.event.release.html_url }} | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_PASSWORD: synapse_password | |
| POSTGRES_USER: synapse_user | |
| POSTGRES_DB: synapse | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: synapse_root_password | |
| MYSQL_DATABASE: synapse | |
| MYSQL_USER: synapse_user | |
| MYSQL_PASSWORD: synapse_password | |
| options: >- | |
| --health-cmd="mysqladmin ping" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=3 | |
| ports: | |
| - 3306:3306 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org/' | |
| - run: corepack enable | |
| - run: yarn config set enableImmutableInstalls false | |
| - run: yarn | |
| - run: yarn build | |
| - run: yarn lint | |
| - run: yarn test | |
| env: | |
| DB_PG: postgresql://synapse_user:synapse_password@localhost:5432/synapse | |
| DB_MYSQL: mysql://synapse_user:synapse_password@localhost:3306/synapse | |
| - name: Check package version | |
| env: | |
| IS_PRERELEASE: ${{ github.event.release.prerelease }} | |
| run: | | |
| PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
| echo "Package version: $PACKAGE_VERSION" | |
| if [[ "$IS_PRERELEASE" == "true" ]]; then | |
| # For prereleases, version must contain -beta | |
| if [[ "$PACKAGE_VERSION" != *"-beta"* ]]; then | |
| echo "❌ Prerelease failed: Package version '$PACKAGE_VERSION' must contain '-beta'" | |
| exit 1 | |
| fi | |
| echo "✅ Prerelease version check passed" | |
| else | |
| # For releases, version must NOT contain -beta | |
| if [[ "$PACKAGE_VERSION" == *"-beta"* ]]; then | |
| echo "❌ Release failed: Package version '$PACKAGE_VERSION' cannot contain '-beta'" | |
| exit 1 | |
| fi | |
| echo "✅ Release version check passed" | |
| fi | |
| - name: Publish to npm | |
| env: | |
| IS_PRERELEASE: ${{ github.event.release.prerelease }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN | |
| if [[ "$IS_PRERELEASE" == "true" ]]; then | |
| npm publish --tag beta | |
| else | |
| npm publish | |
| fi | |
| - name: Send Discord Notification | |
| if: ${{ !github.event.release.prerelease }} | |
| uses: sarisia/actions-status-discord@v1 | |
| with: | |
| webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
| nodetail: true | |
| url: ${{ github.event.release.html_url }} | |
| title: 🚀 **RELEASE** **@digital-alchemy/synapse ${{ github.event.release.tag_name }}** published | |
| content: | | |
| (${{ github.event.release.tag_name }}) **${{ github.event.release.name }}** | |
| ${{ github.event.release.body }} |