diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e4fcbf64ba..36c5d41ad5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,19 +1,29 @@ name: Publish on: - schedule: - - cron: '0 0 * * *' + push: + branches: + - master jobs: - release: - name: Packages - if: github.repository == 'AssemblyScript/assemblyscript' + publish: + name: "Packages" + if: github.repository == 'DuncanUszkay1/assemblyscript' runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 with: - ref: master + ref: release - uses: dcodeIO/setup-node-nvm@master with: node-version: current + - name: Merge master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + git remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" + git fetch origin + git merge origin/master - name: Install dependencies run: npm ci - name: Build distribution files @@ -22,18 +32,41 @@ jobs: npm run build - name: Test distribution files run: npm test - - name: Make semantic release + - name: Set up version + run: | + VERSION=$(node -e "console.log(require('./package.json').version)") + git add --force dist/* + if git rev-parse v$VERSION >/dev/null 2>&1; then + VERSION=$VERSION-nightly.$(date "+%Y%m%d") + if git rev-parse v$VERSION >/dev/null 2>&1; then + echo "Nightly $VERSION does already exist." + exit 1 + fi + echo ::set-env name=CHANNEL::nightly + echo "Committing nightly ($VERSION) ..." + git commit -m "Nightly v$VERSION" + npm version $VERSION --no-git-tag-version --force + else + echo ::set-env name=CHANNEL::latest + echo "Committing release ($VERSION) ..." + git commit --allow-empty -m "Release v$VERSION" + fi + echo ::set-env name=VERSION::$VERSION + cd lib/loader + npm version $VERSION --no-git-tag-version --force + cd ../.. + - name: Create tag and push distribution files + run: | + git tag v$VERSION + git push origin release + git push origin v$VERSION + - name: Publish to npm env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - # On success, semantic-release will update the version and publish, - # triggering the postversion script that'll update the loader's version - # as well. If nothing was published, the version will still be '0.0.0'. + NPM_REGISTRY: "registry.npmjs.org" + NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | - node node_modules/semantic-release/bin/semantic-release.js --unstable + npm config set "//${NPM_REGISTRY}/:_authToken=${NPM_AUTH_TOKEN}" + npm publish --tag $CHANNEL cd lib/loader - if [ $(node -pe "require('./package.json').version") != "0.0.0" ]; then - npm config set "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" - npm publish --access public - fi + npm publish --tag $CHANNEL --access public cd ../.. diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60f636a26a..49597efacf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -68,8 +68,6 @@ jobs: exit 1 fi npm test - - name: Test browser build - run: node tests/browser-asc test-windows: name: "Compiler (Windows, node current)" runs-on: windows-latest @@ -89,8 +87,6 @@ jobs: run: npm run build - name: Test distribution run: npm test - - name: Test browser build - run: node tests/browser-asc test-macos: name: "Compiler (MacOS, node current)" runs-on: macos-latest @@ -110,8 +106,6 @@ jobs: run: npm run build - name: Test distribution run: npm test - - name: Test browser build - run: node tests/browser-asc test-features: name: "Features" runs-on: ubuntu-latest @@ -121,7 +115,8 @@ jobs: - uses: dcodeIO/setup-node-nvm@master with: node-mirror: https://nodejs.org/download/v8-canary/ - node-version: "15.0.0-v8-canary202007077c53168ead" + # FIXME: newer node-v8 builds are currently broken + node-version: "14.0.0-v8-canary201911242015a12d82" - name: Install dependencies run: npm ci --no-audit - name: Clean distribution files