How to create a release/publish build to Github with codemagic workflow?

Viewed 8

Hi I'm attempting to publish an application via Codemagic. I've used React/Electron to build this application on a windows environment, and have no problem creating a build for windows. However, for a Mac I wanted to use codemagic to help me with the build.

I've created a workflow, but I'm confused on how to actually make this build to Github..

  workflows: 
    macos-build:
      name: macOS Build
      instance_type: mac_pro
      environment:
        groups:
          - prod 
        node: 16.14.0

      scripts:
        - name: Injecting env vars
          script: echo "REACT_APP_API_KEY=$REACT_APP_API_KEY" >> .env
        - name: Injecting env vars (2)
          script: echo "GH_TOKEN=$GH_TOKEN" >> .env
        - name: Installing packages
          script: yarn install
        - name: Building Applications - React
          script: yarn build
        - name: Building Application - Electron
          script: yarn electron-builder -m --publish always -c.extraMetadata.main=build/electron.js 

      publishing:
        github: ??


      artifacts:
        - out/make/*.dmg

and from my json.package:

 "build": {
    "productName": "myApp",
    "appId": "com.myApp.app",
    "win": {
      "artifactName": "myApp.exe",
      "icon": "./buildResources/icons/icon.png",
      "target": ["portable"]
    },
    "mac": {
      "artifactName": "myApp.dmg",
      "icon": "./buildResources/icons/icon.png",
      "target": "dmg",
      "publish": ["github"]
    }
  }

I tried creating a release manually on Github, but I get the error when building:

  • overwrite published file  file=myApp.dmg.blockmap reason=already exists on GitHub
  • overwrite published file  file=myApp.dmg reason=already exists on GitHub
  • overwrite published file  file=latest-mac.yml reason=already exists on GitHub

So if I can't overwrite it, I'm confused on how to force it to create the release.

I've tried with:

      publishing:
        scripts:
          -name: github 
          script: |
          gh release create "v1.0.1"

or

      publishing:
          script: |
          gh release create "v1.0.1"

and I get errors like

1 validation error for YamlConfiguration
workflows -> macos-build -> publishing -> scripts
  value is not a valid list (type=type_error.list)

I've been searching online for quite a while to figure out how to do this correctly, I feel like I'm very close. I am a newer developer, just trying to figure this workflow thing out. Does anyone have anymore details or an example on how to actually publish/create a release on Github?

Thank you.

0 Answers
Related