Skip to content

chore: release

chore: release #396

Workflow file for this run

name: Release
on:
push:
branches:
- main
- prerelease
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node.js Env and Test
uses: actions/setup-node@v3
with:
node-version: lts/*
- run: corepack enable
- run: pnpm i
- run: pnpm test
- name: Create Release Pull Request or Publish
id: changesets
# https://github.com/changesets/action
uses: changesets/action@v1
with:
publish: pnpm release
commit: "chore: release"
title: "chore: release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Upload assets
if: ${{ steps.changesets.outputs.published == 'true' }}
run: |
version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[0].version')
echo "version is $version"
# 1. pull tar files by tag (ref name)
curl -fLsS https://get.docker.com/ | sh
# pull amd
docker pull --platform=linux/amd64 zengmingjian/web-ide:$version
docker save zengmingjian/web-ide:$version | gzip > web-ide-$version-linux-amd64.tgz
docker image rm zengmingjian/web-ide:$version
# pull arm
docker pull --platform=linux/arm64 zengmingjian/web-ide:$version
docker save zengmingjian/web-ide:$version | gzip > web-ide-$version-linux-arm64.tgz
docker image rm zengmingjian/web-ide:$version
ls -al
# 2. upload tar files
release_id=$(
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/zanminkian/web-ide/releases/tags/v$version" | jq -r ".id"
)
echo "release id is $release_id"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/zanminkian/web-ide/releases/$release_id/assets?name=web-ide-$version-linux-amd64.tgz" \
-T "web-ide-$version-linux-amd64.tgz" >/dev/null 2>&1
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/zanminkian/web-ide/releases/$release_id/assets?name=web-ide-$version-linux-arm64.tgz" \
-T "web-ide-$version-linux-arm64.tgz" >/dev/null 2>&1