diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd2c6a7f0a..d2d026323a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -52,89 +52,115 @@ jobs: uses: actions/setup-node@v4 with: node-version: 20.x - - name: Build Node.js package + - name: Builder browser package run: | npm install - node ./tools/build.js -t node - npm test - - - name: Publish highlight.js to NPM - id: publish - uses: JS-DevTools/npm-publish@v3 - with: - check-version: true - token: ${{ secrets.NPM_TOKEN }} - package: ./build/package.json - tag: ${{ env.NPM_TAG }} - - - if: steps.publish.outputs.type != 'none' - run: | - echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}" - - # if stable release - - name: Stable Release - if: env.RELEASING == 'stable' - run: echo "BRANCH_NAME=${MAJOR_VERSION}-stable" >> $GITHUB_ENV - # else (beta) - - name: Beta Release - if: env.RELEASING == 'beta' - run: echo "BRANCH_NAME=main" >> $GITHUB_ENV - - name: Confirm release is either stable or beta - if: ${{ !(env.RELEASING == 'stable' || env.RELEASING == 'beta') }} - run: | - echo We seem to be releasing `${RELEASING}`. - false - - - name: Checkout cdn-release - uses: actions/checkout@v4 + node ./tools/build.js -t browser :common + # npm run test-browser + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - repository: 'highlightjs/cdn-release' - path: 'cdn-release' - token: ${{ secrets.CDN_REPO_TOKEN }} - ref: ${{ env.BRANCH_NAME }} - - - name: Build CDN package - run: node ./tools/build.js -t cdn :common - - - name: Commmit & Push cdn-release ${{ env.TAG_NAME }} - working-directory: ./cdn-release - run: | - rm -r ./build - mv ../build/ ./build/ - mv ./build/DIGESTS.md . - git config user.name github-actions - git config user.email github-actions@github.com - git add ./build/ - git add ./DIGESTS.md - git commit -m'Update to version ${{ env.TAG_NAME }}' - git tag ${TAG_NAME} - git push -f --atomic origin ${BRANCH_NAME} ${TAG_NAME} - - - name: Publish cdn-assets to NPM - id: publish_cdn - uses: JS-DevTools/npm-publish@v3 + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: true + # todo: determine this auto-magically + prerelease: ${{ !(env.RELEASING == 'stable') }} + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - check-version: true - token: ${{ secrets.NPM_TOKEN }} - package: ./cdn-release/build/package.json - tag: ${{ env.NPM_TAG }} - - # log.info('Updating CDN repo at %s' % settings.HLJS_CDN_SOURCE) - # run(['nodejs', 'tools/build.js', '--target', 'cdn', ':common']) - # os.chdir(settings.HLJS_CDN_SOURCE) - # run(['git', 'pull', '-f']) - # lines = run(['git', '--git-dir', os.path.join(settings.HLJS_CDN_SOURCE, '.git'), 'tag']) - # build_dir = os.path.join(settings.HLJS_CDN_SOURCE, 'build') - # if version in lines: - # log.info('Tag %s already exists in the local CDN repo' % version) - # else: - # if os.path.exists(build_dir): - # shutil.rmtree(build_dir) - # shutil.move(os.path.join(settings.HLJS_SOURCE, 'build'), build_dir) - # run(['git', 'add', '.']) - # run(['git', 'commit', '-m', 'Update to version %s' % version]) - # run(['git', 'tag', version]) - # run(['git', 'push']) - # run(['git', 'push', '--tags']) - # npm_publish(build_dir) - # os.chdir(settings.HLJS_SOURCE) + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./build/highlight.js + asset_name: highlight.js + asset_content_type: text/javascript + # - name: Build Node.js package + # run: | + # npm install + # node ./tools/build.js -t node + # npm test + + # - name: Publish highlight.js to NPM + # id: publish + # uses: JS-DevTools/npm-publish@v3 + # with: + # check-version: true + # token: ${{ secrets.NPM_TOKEN }} + # package: ./build/package.json + # tag: ${{ env.NPM_TAG }} + + # - if: steps.publish.outputs.type != 'none' + # run: | + # echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}" + + # # if stable release + # - name: Stable Release + # if: env.RELEASING == 'stable' + # run: echo "BRANCH_NAME=${MAJOR_VERSION}-stable" >> $GITHUB_ENV + # # else (beta) + # - name: Beta Release + # if: env.RELEASING == 'beta' + # run: echo "BRANCH_NAME=main" >> $GITHUB_ENV + # - name: Confirm release is either stable or beta + # if: ${{ !(env.RELEASING == 'stable' || env.RELEASING == 'beta') }} + # run: | + # echo We seem to be releasing `${RELEASING}`. + # false + + # - name: Checkout cdn-release + # uses: actions/checkout@v4 + # with: + # repository: 'highlightjs/cdn-release' + # path: 'cdn-release' + # token: ${{ secrets.CDN_REPO_TOKEN }} + # ref: ${{ env.BRANCH_NAME }} + + # - name: Build CDN package + # run: node ./tools/build.js -t cdn :common + + # - name: Commmit & Push cdn-release ${{ env.TAG_NAME }} + # working-directory: ./cdn-release + # run: | + # rm -r ./build + # mv ../build/ ./build/ + # mv ./build/DIGESTS.md . + # git config user.name github-actions + # git config user.email github-actions@github.com + # git add ./build/ + # git add ./DIGESTS.md + # git commit -m'Update to version ${{ env.TAG_NAME }}' + # git tag ${TAG_NAME} + # git push -f --atomic origin ${BRANCH_NAME} ${TAG_NAME} + + # - name: Publish cdn-assets to NPM + # id: publish_cdn + # uses: JS-DevTools/npm-publish@v3 + # with: + # check-version: true + # token: ${{ secrets.NPM_TOKEN }} + # package: ./cdn-release/build/package.json + # tag: ${{ env.NPM_TAG }} + + # # log.info('Updating CDN repo at %s' % settings.HLJS_CDN_SOURCE) + # # run(['nodejs', 'tools/build.js', '--target', 'cdn', ':common']) + # # os.chdir(settings.HLJS_CDN_SOURCE) + # # run(['git', 'pull', '-f']) + # # lines = run(['git', '--git-dir', os.path.join(settings.HLJS_CDN_SOURCE, '.git'), 'tag']) + # # build_dir = os.path.join(settings.HLJS_CDN_SOURCE, 'build') + # # if version in lines: + # # log.info('Tag %s already exists in the local CDN repo' % version) + # # else: + # # if os.path.exists(build_dir): + # # shutil.rmtree(build_dir) + # # shutil.move(os.path.join(settings.HLJS_SOURCE, 'build'), build_dir) + # # run(['git', 'add', '.']) + # # run(['git', 'commit', '-m', 'Update to version %s' % version]) + # # run(['git', 'tag', version]) + # # run(['git', 'push']) + # # run(['git', 'push', '--tags']) + # # npm_publish(build_dir) + # # os.chdir(settings.HLJS_SOURCE)