|
| 1 | +name: Publish Book and Article as a GH Release |
| 2 | + |
| 3 | +# here's the content of a published theme zip |
| 4 | +# build/ |
| 5 | +# public/ |
| 6 | +# template.yml |
| 7 | +# package-lock.json package.json |
| 8 | +# server.js |
| 9 | +# README.md (copied from the GH repo - hopefully not needed) |
| 10 | + |
| 11 | +# -- as per Makefile they come from |
| 12 | +# build: themes/$(THEME)/build/ (built) |
| 13 | +# public: themes/$(THEME)/public/ (built) |
| 14 | +# template.yml: themes/$(THEME)/ (built) |
| 15 | +# package.json: template/ (sed template->$(THEME) and VERSION->$(VERSION) |
| 16 | +# server.js: template/ (as-is from repo) |
| 17 | + |
| 18 | +# Note: xxx this workflow does not publish to npm for now |
| 19 | + |
| 20 | +# not triggering on branch pushes |
| 21 | +# note that this will trigger only once if several tags are pushed in a batch |
| 22 | +on: |
| 23 | + push: |
| 24 | + # branches: [ main ] |
| 25 | + tags: [ '*' ] |
| 26 | + |
| 27 | +jobs: |
| 28 | + github-release: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout repo |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Set up Node |
| 36 | + uses: actions/setup-node@v4 |
| 37 | + with: |
| 38 | + node-version: 24 |
| 39 | + |
| 40 | + - name: Install dependencies |
| 41 | + run: npm install |
| 42 | + - name: Build |
| 43 | + run: npm run build |
| 44 | + - name: Run tests |
| 45 | + run: npm run test |
| 46 | + |
| 47 | + - name: build book |
| 48 | + run: cd themes/book && npm run prod:build |
| 49 | + - name: build article |
| 50 | + run: cd themes/article && npm run prod:build |
| 51 | + |
| 52 | + - name: package book |
| 53 | + run: | |
| 54 | + rm -rf dist-book && mkdir dist-book |
| 55 | + cp -r themes/book/public dist-book/public |
| 56 | + cp -r themes/book/build dist-book/build |
| 57 | + cp -r themes/book/template.yml dist-book/template.yml |
| 58 | + cp template/server.js dist-book/server.js |
| 59 | + VERSION=$(node -p "require('./packages/site/package.json').version") && sed -e "s/VERSION/$VERSION/g" -e "s/THEME/book/g" template/package.json > dist-book/package.json |
| 60 | + cd dist-book && npm install |
| 61 | +
|
| 62 | + - name: package article |
| 63 | + run: | |
| 64 | + rm -rf dist-article && mkdir dist-article |
| 65 | + cp -r themes/article/public dist-article/public |
| 66 | + cp -r themes/article/build dist-article/build |
| 67 | + cp -r themes/article/template.yml dist-article/template.yml |
| 68 | + cp template/server.js dist-article/server.js |
| 69 | + VERSION=$(node -p "require('./packages/site/package.json').version") && sed -e "s/VERSION/$VERSION/g" -e "s/THEME/article/g" template/package.json > dist-article/package.json |
| 70 | + cd dist-article && npm install |
| 71 | +
|
| 72 | + # xxx publishing to npm kept out of this workflow for now |
| 73 | + |
| 74 | + # Create zips |
| 75 | + - name: zip artifacts |
| 76 | + run: | |
| 77 | + mkdir dist_zip |
| 78 | + zip -r dist_zip/book.zip dist-book/ |
| 79 | + zip -r dist_zip/article.zip dist-article/ |
| 80 | +
|
| 81 | + # Determine version/tag for naming |
| 82 | + # if this is a tagged build, use the tag |
| 83 | + - name: Determine release name |
| 84 | + id: vars |
| 85 | + run: | |
| 86 | + if [[ $GITHUB_REF == refs/tags/* ]]; then |
| 87 | + TAG="${GITHUB_REF#refs/tags/}" |
| 88 | + echo "name=${TAG}" >> $GITHUB_OUTPUT |
| 89 | + else |
| 90 | + echo name=$(cut -c1-7 <<< "${GITHUB_SHA}") >> $GITHUB_OUTPUT |
| 91 | + fi |
| 92 | +
|
| 93 | + # Publish both zips as release assets |
| 94 | + - name: Upload release assets |
| 95 | + uses: softprops/action-gh-release@v2 |
| 96 | + with: |
| 97 | + name: "Build ${{ steps.vars.outputs.name }}" |
| 98 | + tag_name: "${{ steps.vars.outputs.name }}" |
| 99 | + files: | |
| 100 | + dist_zip/book.zip |
| 101 | + dist_zip/article.zip |
| 102 | + env: |
| 103 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments