Skip to content

Update publish script #56

Update publish script

Update publish script #56

Workflow file for this run

name: Build and publish
on:
pull_request:
types: [closed]
branches:
- master
- develop
- beta
- stable
- test-publish
jobs:
create_release:
if: github.event.pull_request.merged
name: Create release
runs-on: ubuntu-20.04
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.export_outputs.outputs.version }}
branch: ${{ steps.export_outputs.outputs.branch }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set Versions
run: |
bash ./scripts/set_versions_ga.sh
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
draft: false
prerelease: true
- name: Export outputs
id: export_outputs
run: |
echo "::set-output name=version::$VERSION"
echo "::set-output name=branch::$BRANCH"
build_and_publish:
if: github.event.pull_request.merged
needs: create_release
name: Build and publish for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-20.04
asset_name: ima-${{ needs.create_release.outputs.version }}-Linux-x86_64
- os: macos-latest
asset_name: ima-${{ needs.create_release.outputs.version }}-Darwin-x86_64
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-node@v1
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- uses: oven-sh/setup-bun@v1
- name: Install dependencies
run: |
yarn install
- name: Yarn build
if: matrix.os == 'ubuntu-20.04'
run: |
yarn prepack
- name: Publish on npm
if: matrix.os == 'ubuntu-20.04'
run: |
if [[ ${{ needs.create_release.outputs.branch }} == "stable" ]]; then
npm publish --access public
else
npm version --no-git-tag-version ${{ needs.create_release.outputs.version }} --allow-same-version
npm publish --access public --tag ${{ needs.create_release.outputs.branch }}
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build CLI
run: |
bun build:exec
mv ima ima-${{ needs.create_release.outputs.version }}
- name: Upload Release Asset Ubuntu
if: matrix.os == 'ubuntu-20.04'
id: upload-release-asset-ubuntu
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{ matrix.asset_name }}
asset_name: ${{ matrix.asset_name }}
asset_content_type: application/octet-stream
- name: Upload Release Asset Mac
if: matrix.os == 'macos-latest'
id: upload-release-asset-mac
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{ matrix.asset_name }}
asset_name: ${{ matrix.asset_name }}
asset_content_type: application/octet-stream