Skip to content

release test

release test #9

Workflow file for this run

name: CD-Source
on:
pull_request:
jobs:
Build-Binaries:
name: Build binaries
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- x64
- arm64
node-version:
- node18
os:
- linux
- macos
- win
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Read VERSION into env.RELEASE_VERSION
run: echo RELEASE_VERSION=0.11.5 >> $GITHUB_ENV
- name: Is Pre-Release
run: |
STR="${RELEASE_VERSION}"
SUB='pre.'
if [[ "$STR" == *"$SUB"* ]]; then
echo PRE_RELEASE=true >> $GITHUB_ENV
else
echo PRE_RELEASE=false >> $GITHUB_ENV
fi
- name: Check If Tag Exists
id: tag_check
shell: bash -ex {0}
run: |
GET_API_URL="https://api.github.com/repos/${{github.repository}}/git/ref/tags/${{env.RELEASE_VERSION}}"
http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \
-H "Authorization: token ${GITHUB_TOKEN}")
if [ "$http_status_code" -ne "404" ] ; then
echo TAG_EXISTS=true >> $GITHUB_ENV
else
echo TAG_EXISTS=false >> $GITHUB_ENV
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Read .nvmrc into env.NVMRC
if: env.TAG_EXISTS == 'false'
run: echo NVMRC=$(cat .nvmrc) >> $GITHUB_ENV
- name: Setup Node.js
if: env.TAG_EXISTS == 'false'
uses: actions/setup-node@v1
with:
node-version: '${{env.NVMRC}}'
- name: Install Rust
if: env.TAG_EXISTS == 'false'
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Build CLI
if: env.TAG_EXISTS == 'false'
run: |
yarn install
yarn build
- name: Package into standalone binary
if: env.TAG_EXISTS == 'false' && ${{ matrix.arch }} == 'arm64'
uses: uraimo/run-on-arch-action@v2
with:
arch: aarch64
distro: ubuntu18.04
githubToken: ${{ secrets.GITHUB_TOKEN }}
# We need to install node and yarn "again" because they dont exist inside our build container
install: |
apt update && apt -y install curl
curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
apt-get install -y nodejs
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt update && apt -y install yarn
yarn global add [email protected] --prefix /usr/local
pkg --version
run: |
pkg \
--config ./packages/cli/package.json \
--target=${{ matrix.node-version }}-${{ matrix.os }}-${{ matrix.arch }} \
--output ./packages/cli/standalone-binaries/polywrap-${{ matrix.os }}-${{ matrix.arch }} \
--debug \
--compress Brotli \
./packages/cli/bin/polywrap
- name: Package into standalone binary
if: env.TAG_EXISTS == 'false' && ${{ matrix.arch }} == 'x64'
working-directory: ./packages/cli
run: |
npx pkg . --target=${{ matrix.node-version }}-${{ matrix.os }}-${{ matrix.arch }} --output ./standalone-binaries/polywrap-${{ matrix.os }}-${{ matrix.arch }} --compress Brotli
- name: Extract binary path
if: env.TAG_EXISTS == 'false' && ${{ matrix.arch }} == 'x64'
run: echo STANDALONE_BINARY_PATH=$(stat ./packages/cli/standalone-binaries/polywrap-${{ matrix.os }}-${{ matrix.arch }} | awk '/File:/ {print $2}') >> $GITHUB_ENV
- name: Upload Artifacts
if: env.TAG_EXISTS == 'false'
uses: actions/upload-artifact@v3
with:
name: polywrap-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ env.STANDALONE_BINARY_PATH }}
Publish-GitHub:
name: Publish source to github.com
needs: Build-Binaries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Read VERSION into env.RELEASE_VERSION
run: echo RELEASE_VERSION=0.11.5 >> $GITHUB_ENV
- name: Is Pre-Release
run: |
STR="${RELEASE_VERSION}"
SUB='pre.'
if [[ "$STR" == *"$SUB"* ]]; then
echo PRE_RELEASE=true >> $GITHUB_ENV
else
echo PRE_RELEASE=false >> $GITHUB_ENV
fi
- name: Check If Tag Exists
id: tag_check
shell: bash -ex {0}
run: |
GET_API_URL="https://api.github.com/repos/${{github.repository}}/git/ref/tags/${{env.RELEASE_VERSION}}"
http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \
-H "Authorization: token ${GITHUB_TOKEN}")
if [ "$http_status_code" -ne "404" ] ; then
echo TAG_EXISTS=true >> $GITHUB_ENV
else
echo TAG_EXISTS=false >> $GITHUB_ENV
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set Git Identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{github.repository}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Git Tag
if: env.TAG_EXISTS == 'false'
uses: azu/action-package-version-to-git-tag@v1
with:
version: ${{ env.RELEASE_VERSION }}
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repo: ${{ github.repository }}
git_commit_sha: ${{ github.event.pull_request.merge_commit_sha }}
- name: Download Artifacts linux-x64
uses: actions/download-artifact@v3
with:
name: polywrap-linux-x64
path: ./bin/polywrap-linux-x64
- name: Download Artifacts linux-arm64
uses: actions/download-artifact@v3
with:
name: polywrap-linux-arm64
path: ./bin/polywrap-linux-arm64
- name: Download Artifacts macos-x64
uses: actions/download-artifact@v3
with:
name: polywrap-macos-x64
path: ./bin/polywrap-macos-x64
- name: Download Artifacts macos-arm64
uses: actions/download-artifact@v3
with:
name: polywrap-macos-arm64
path: ./bin/polywrap-macos-arm64
- name: Download Artifacts win-x64
uses: actions/download-artifact@v3
with:
name: polywrap-win-x64
path: ./bin/polywrap-win-x64
- name: Download Artifacts win-arm64
uses: actions/download-artifact@v3
with:
name: polywrap-win-arm64
path: ./bin/polywrap-win-arm64
- name: Create Release
id: create_release
if: env.PRE_RELEASE == 'false' && env.TAG_EXISTS == 'false'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
# Copy Pull Request's tile and body to Release Note
name: ${{ github.event.pull_request.title }}
body: |
${{ github.event.pull_request.body }}
draft: true
prerelease: false
files: |
./bin/polywrap-linux-x64
./bin/polywrap-linux-arm64
./bin/polywrap-macos-x64
./bin/polywrap-macos-arm64
./bin/polywrap-win-x64
./bin/polywrap-win-arm64
- uses: actions/[email protected]
if: env.TAG_EXISTS == 'false'
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '**[GitHub Release Published](https://github.com/${{ github.repository }}/releases/tag/${{ env.RELEASE_VERSION }}) `${{env.RELEASE_VERSION}}`** 🎉'
})