Combine nightly and autopublish workflows
ADD
.github/actions/setup/action.yml
+name: Setup
+runs:
+ using: "composite"
+ steps:
+ - uses: actions/setup-node@v1
+ with:
+ node-version: '14.16.0'
+ registry-url: 'https://registry.npmjs.org'

MODIFY
.github/workflows/autopublish.yml
.github/workflows/autopublish.yml
name: Auto-publish
on:
+ schedule:
+ - cron: '0 0 * * *'
push:
branches:
- main
@@ -8,68 +10,82 @@ on:
jobs:
check:
- name: Check version update
+ name: Check if there was a version update
runs-on: ubuntu-latest
- outputs:
- changed: ${{ steps.check.outputs.changed }}
- version: ${{ steps.check.outputs.version }}
- type: ${{ steps.check.outputs.type }}
steps:
- uses: actions/checkout@v2
+ - name: Set default release tag
+ run: echo "tag=latest" >> $GITHUB_ENV
+
+ - name: Check nightly status
+ id: nightly
+ if: github.event_name == 'schedule'
+ run:
+ - echo "tag=nightly" >> $GITHUB_ENV
+ - echo "nightly=true" >> $GITHUB_ENV
+
- name: Check version changes
uses: EndBug/version-check@v1
- id: check
+ id: version
with:
diff-search: true
- publish:
- name: Publish
+ - run: echo "version=${{ steps.version.outputs.version }}" >> $GITHUB_ENV
+
+ - name: Check prerelease status
+ id: prerelease
+ if: steps.version.outputs.type == 'prerelease' || steps.version.outputs.type == 'prepatch' || steps.version.outputs.type == 'premajor' || steps.version.outputs.type == 'preminor'
+ run: echo "prerelease=true" >> $GITHUB_ENV
+
+ - name: Check version status
+ if: steps.version.outputs.changed == 'true'
+ run:
+ - echo "version_changed=true" >> $GITHUB_ENV
+ - 'echo "Version change found! New version: ${{ steps.version.outputs.version }} (${{ steps.version.outputs.version_type }})"'
+
+ build:
+ name: Build Release
needs: check
- if: needs.check.outputs.changed == 'true'
- environment: npm-publish
+ if: env.version_changed == 'true' || env.nightly == 'true'
runs-on: ubuntu-latest
steps:
- - name: Version update detected
- run: 'echo "Version change found! New version: ${{ needs.check.outputs.version }} (${{ needs.check.outputs.type }})"'
-
- uses: actions/checkout@v2
+ - uses: ./.github/actions/setup
- - uses: actions/setup-node@v1
- with:
- node-version: '14.16.0'
- registry-url: 'https://registry.npmjs.org'
+ - name: Set tag if prerelease
+ if: needs.check.outputs.prerelease == 'true'
+ run: echo "tag=prerelease" >> $GITHUB_ENV
- - run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
+ - name: Update version if nightly
+ if: needs.check.outputs.nightly == 'true'
+ run:
+ - ./rome run scripts/update-nightly-version
+ - NEW_VERSION=$(./rome --version)
+ - echo "version=$NEW_VERSION" >> $GITHUB_ENV
+ - echo "tag=nightly" >> $GITHUB_ENV
- - name: Build Release
+ - name: Build package
run: ./rome run scripts/build-release dist
- - name: Check if prerelease
- id: check-prelease
- if: needs.check.outputs.type == 'prerelease' || needs.check.outputs.type == 'prepatch' || needs.check.outputs.type == 'premajor' || needs.check.outputs.type == 'preminor'
- run: echo "::set-output name=prerelease::true"
-
- - name: Publish to npm as latest
- if: steps.check-prelease.outputs.prelease != 'true'
- run: npm publish dist --tag latest
- env:
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ - name: Build tarball
+ run: tar -C dist -cvzf dist.tar.gz .
- - name: Publish to npm as prerelease
- if: steps.check-prelease.outputs.prelease == 'true'
- run: npm publish dist --tag prerelease
- env:
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ if-no-files-found: error
+ with:
+ name: dist.tar.gz
+ path: dist.tar.gz
+ retention-days: 5
- # TODO update branch
+ publish:
+ name: Publish Release
+ needs: build
+ runs-on: ubuntu-latest
+ run:
+ - uses: actions/checkout@v2
+ - uses: ./.github/actions/setup
- - name: Create Release and tag
- uses: actions/create-release@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- tag_name: v${{ needs.check.outputs.version }}
- release_name: v${{ needs.check.outputs.version }}
- draft: false
- prerelease: false
+ - run:
+ - echo "Publishing ${{ env.version }} ${{ env.tag }}"

MODIFY
.github/workflows/ci.yml
.github/workflows/ci.yml
@@ -14,9 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- - uses: actions/setup-node@v1
- with:
- node-version: '14.16.0'
+ - uses: ./.github/actions/setup
- name: rome ci
run: ./rome ci
@@ -30,9 +28,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- - uses: actions/setup-node@v1
- with:
- node-version: '14.16.0'
+ - uses: ./.github/actions/setup
- name: rome test
run: ./rome test --freeze-snapshots
@@ -42,9 +38,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- - uses: actions/setup-node@v1
- with:
- node-version: '14.16.0'
+ - uses: ./.github/actions/setup
- name: Run TypeScript
run: node ./node_modules/.bin/tsc --noEmit
@@ -54,8 +48,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- - uses: actions/setup-node@v1
- with:
- node-version: '14.16.0'
+ - uses: ./.github/actions/setup
- name: Check if generated files need to be updated
run: ./rome run scripts/generate-all-files

DELETE
.github/workflows/nightly.yml
-name: Nightly Release
-on:
- schedule:
- - cron: '0 0 * * *'
-
-jobs:
- nightly_release:
- name: Nightly Release
- environment: npm-publish
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-node@v1
- with:
- node-version: '14.16.0'
- registry-url: 'https://registry.npmjs.org'
- - name: Build Release
- run: ./rome run scripts/build-nightly
- # Publish to npm
- - name: Publish to npm
- run: npm publish dist --tag nightly
- env:
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- # TODO create a git tag
- # TODO: Publish to GitHub?

MODIFY
.gitignore
.gitignore
.DS_Store
Profile-*.json
+# Editor configuration
.vscode
.idea
-# ignore test files that contributors could create locally
-/test.*
+# Release artifacts
/dist
+/dist.tar.gz
+# Ignore test files that contributors could create locally
+/test.*

RENAME
scripts/build-nightly.ts
scripts/update-nightly-version.ts
-import {PUBLIC_PACKAGES, ROOT, execDev} from "./_utils";
+import {ROOT} from "./_utils";
import {runNPMVersion} from "./update-version";
import {VERSION} from "@internal/core";
@@ -11,13 +11,4 @@ export async function main() {
// And then update it
await runNPMVersion([newVersion], ROOT);
-
- // Build a release to the dist folder in the root
- await execDev([
- "bundle",
- PUBLIC_PACKAGES.append("rome").join(),
- ROOT.append("dist").join(),
- "--set-version",
- newVersion,
- ]);
}

Combine nightly and autopublish workflows