4

I want to publish a whole directory (the build directory) on a Github release using semantic-release but unfortunately it releases each build file as a single asset.

For reproduction:

  • I'm using the Vue CLI to generate a project vue create foo
  • Install semantic-release as a dev dependency npm install --save-dev semantic-release
  • Install the Github plugin for semantic-release npm install @semantic-release/github -D
  • Create a .releaserc.json with the content

.

{
    "plugins":[
      "@semantic-release/commit-analyzer",
      "@semantic-release/release-notes-generator",
      [
        "@semantic-release/github",
        {
          "assets":[
            {
              "path":"dist",
              "label":"foo-${nextRelease.gitTag}"
            }
          ]
        }
      ]
    ]
  }
  • Inside the package.json set the version key to 0.0.0-development
  • Create a .github/workflows directory with the workflow ci.yml

.

name: CI

on:
  push:
    branches:
      - main

jobs:
  ci:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: 16.x

      - name: Install dependencies
        run: npm install

      - name: Run build
        run: npm run build

      - name: Release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: npx semantic-release --branches main
  • Commit and push it with feat: pushed

The release seems to be fine but unfortunately it didn't publish the dist directory as a single asset.

enter image description here

It simply published each file inside dist as a single

enter image description here

Adding the step

  - name: Log
    run: ls

shows that the dist directory exists

enter image description here

How can I fix that?

Question3r
  • 2,166
  • 19
  • 100
  • 200

1 Answers1

1

It seems this is not possible. So I have to add this step after building the app

  - name: ZIP build
    run: zip -r dist.zip dist

and set the assets config to

        {
          "path":"dist.zip",
          "label":"foo-${nextRelease.gitTag}.zip"
        }
Question3r
  • 2,166
  • 19
  • 100
  • 200
  • this forces you to build the app on each commit even it doesn't generate a release, instead, you need to build the app inside the releasing process. – Sh eldeeb May 16 '22 at 23:24