chore(dev-cli): bump image version #63
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: π¨βπ» Test & Deploy AO CLI | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- "dev-cli/**" | |
push: | |
branches: | |
- main | |
paths: | |
- "dev-cli/**" | |
# Perform a release using a workflow dispatch | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "semver version to bump to" | |
required: true | |
defaults: | |
run: | |
shell: bash | |
working-directory: dev-cli | |
jobs: | |
# Run only run tests on PRs and pushes to main | |
test: | |
if: github.event_name != 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
deno-version: [1.x] | |
steps: | |
- name: β¬οΈ Checkout repo | |
uses: actions/checkout@v3 | |
- name: π¦ Setup Deno | |
uses: denoland/setup-deno@v1 | |
with: | |
deno-version: ${{ matrix.deno-version }} | |
- name: β‘ Run Tests | |
run: | | |
deno task test | |
env: | |
CI: true | |
test-node-commands: | |
if: github.event_name != 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
steps: | |
- name: β¬οΈ Checkout repo | |
uses: actions/checkout@v3 | |
- name: β Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: π₯ Download deps | |
uses: bahmutov/npm-install@v1 | |
with: | |
working-directory: dev-cli/container/src/node | |
- name: β‘ Run Tests | |
working-directory: dev-cli/container/src/node | |
run: | | |
npm test | |
env: | |
CI: true | |
release: | |
# Releases are performed via a workflow dispatch | |
if: github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
concurrency: | |
group: release | |
steps: | |
- name: β¬οΈ Checkout repo | |
uses: actions/checkout@v3 | |
- name: π¦ Setup Deno | |
uses: denoland/setup-deno@v1 | |
with: | |
deno-version: 1.x | |
- name: β Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: π₯ Download deps | |
uses: bahmutov/npm-install@v1 | |
with: | |
working-directory: dev-cli/tools/deploy | |
- name: π Env | |
run: | | |
echo "Event name: ${{ github.event_name }}" | |
echo "Git ref: ${{ github.ref }}" | |
echo "GH actor: ${{ github.actor }}" | |
echo "SHA: ${{ github.sha }}" | |
VER=`node --version`; echo "Node ver: $VER" | |
VER=`npm --version`; echo "npm ver: $VER" | |
VER=`deno --version`; echo "deno ver: $VER" | |
# The version in the manifest is used to set the version | |
# displayed for the CI. So we need to update version, | |
# prior to building the binaries | |
# | |
# So we update version here. If CI fails, then that bump is | |
# never pushed. If it succeeds, the CI will push any changes to the | |
# manifest, including the version bump, which is what we want | |
- name: πΊ Update Version | |
id: version | |
run: | | |
VERSION=$(deno task bump --version=${INPUT_VERSION}) | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
env: | |
INPUT_VERSION: ${{ github.event.inputs.version }} | |
- name: π Build Binaries | |
id: build_binaries | |
run: | | |
BINARIES_OUTPUT_DIR=$(\ | |
deno task build-binaries \ | |
| tail -1 | |
) | |
echo "binaries_output_dir=${BINARIES_OUTPUT_DIR}" >> $GITHUB_OUTPUT | |
env: | |
CI: true | |
- name: Install Irys Client | |
run: | | |
npm i -g @irys/[email protected] | |
- name: πΎ Publish Binaries to Arweave | |
id: publish_binaries | |
# Irys may fail to deploy the binaries to Arweave for a number of reasons | |
# | |
# So before attempting to extract the transaction id from the output | |
# We first check to make sure the success message is output | |
# | |
# If the deploy was successful, We output text to stdout, the final line containing | |
# the url of the transaction. We only need the transaction id | |
# | |
# So we tail the output and strip the last part of the printed url | |
# which should be the transaction id | |
# | |
# We also add additional tags in order to mint $U | |
run: | | |
irys balance ${CI_WALLET_ADDRESS} \ | |
-h ${IRYS_NODE} \ | |
-t arweave | |
irys price $(du -b "${BINARIES_OUTPUT_DIR}" | cut -f1) \ | |
-h ${IRYS_NODE} \ | |
-t arweave | |
IRYS_RESULT=$(deno task deploy-binaries) | |
echo "${IRYS_RESULT}" | |
if [[ -z $(echo "${IRYS_RESULT}" | awk '/^Uploaded to https:\/\/arweave.net\//') ]]; then | |
echo "Binaries were not successfully deployed to Irys! See above logs." | |
exit 1 | |
fi | |
TRANSACTION_ID=$(\ | |
echo "${IRYS_RESULT}" \ | |
| tail -1 \ | |
| awk -F/ '{print $NF}' | |
) | |
echo "tx_id=${TRANSACTION_ID}" >> $GITHUB_OUTPUT | |
env: | |
CI_WALLET_ADDRESS: ${{ secrets.CI_WALLET_ADDRESS }} | |
BINARIES_OUTPUT_DIR: ${{ steps.build_binaries.outputs.binaries_output_dir }} | |
IRYS_NODE: https://node2.irys.xyz | |
CI_WALLET: ${{ secrets.CI_WALLET }} | |
- name: π Build Install Script | |
id: build_install_script | |
run: | | |
INSTALL_SCRIPT=$(deno task build-install-script --binaries=${BINARIES_TRANSACTION_ID}) | |
echo "install_script=${INSTALL_SCRIPT}" >> $GITHUB_OUTPUT | |
env: | |
CI: true | |
BINARIES_TRANSACTION_ID: ${{ steps.publish_binaries.outputs.tx_id }} | |
- name: π Publish Install Script to Arweave | |
id: publish_install | |
# We output text to stdout, the final line containing | |
# the url of the transaction. We only need the transaction id | |
# | |
# So we tail the output and strip the last part of the printed url | |
# which should be the transaction id | |
run: | | |
IRYS_RESULT=$(deno task deploy-install-script) | |
echo "${IRYS_RESULT}" | |
if [[ -z $(echo "${IRYS_RESULT}" | awk '/^Uploaded to https:\/\/arweave.net\//') ]]; then | |
echo "Binaries were not successfully deployed to Irys! See above logs." | |
exit 1 | |
fi | |
TRANSACTION_ID=$(\ | |
echo "${IRYS_RESULT}" \ | |
| tail -1 \ | |
| awk -F/ '{print $NF}' | |
) | |
echo "tx_id=${TRANSACTION_ID}" >> $GITHUB_OUTPUT | |
env: | |
IRYS_NODE: https://node2.irys.xyz | |
CI_WALLET: ${{ secrets.CI_WALLET }} | |
INSTALL_SCRIPT: ${{ steps.build_install_script.outputs.install_script }} | |
- name: π€ Set Git User | |
run: | | |
git config --global user.name "${{ github.actor }}" | |
git config --global user.email "${{ github.actor }}@users.noreply.github.com" | |
# Until we use something like ArNS, we need a way to keep track of the transactions | |
# that contain the ao CLI | |
# | |
# So we will persist the transaction ids into this file, committed as part of this CI | |
- name: πΊοΈ Update txMappings | |
run: | | |
deno task tx-mappings \ | |
--version=${VERSION} \ | |
--binaries=${BINARIES_TRANSACTION_ID} \ | |
--install=${INSTALL_TRANSACTION_ID} \ | |
--latest | |
deno fmt deno.json | |
env: | |
VERSION: ${{ steps.version.outputs.version }} | |
BINARIES_TRANSACTION_ID: ${{ steps.publish_binaries.outputs.tx_id }} | |
INSTALL_TRANSACTION_ID: ${{ steps.publish_install.outputs.tx_id }} | |
- name: β¬οΈ Push | |
# We purposefully don't use "--follow-tags" here | |
# | |
# Git will push tags in parallel when using '--follow-tags'. | |
# So if the tip of trunk has changed, this will cause the tag to be pushed, but not the commit. | |
# | |
# To get around this, we first attempt to push the commit. If it succeeds, the tag is then pushed. | |
# If pushing the commit fails, then the step fails and no tag is pushed up, which is what we want. | |
run: | | |
git add deno.json src/versions.js | |
git commit -m "chore(dev-cli): bump version and update txMappings" | |
git push | |
git push --tags |