chore(workflows): add publishing ci workflow #104
Workflow file for this run
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: Arweave Name Token | |
on: [push, workflow_dispatch] | |
jobs: | |
unit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
name: Check out repository code | |
- name: Setup Lua | |
uses: leafo/gh-actions-lua@v10 | |
with: | |
luaVersion: '5.3' # Specify the Lua version you need | |
- name: Setup LuaRocks | |
uses: leafo/[email protected] | |
- name: Install Busted | |
run: luarocks install ar-io-ao-0.1-1.rockspec | |
- name: Run Busted Tests | |
run: busted . | |
- name: Upload coverage reports to Codecov | |
uses: codecov/[email protected] | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
# TODO: add ar-io-sdk e2e tests against lua code to be bundled on changes (e.g. create a new ant, publish it and validate it works with the sdk) | |
integration: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/[email protected] | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'yarn' | |
- run: yarn --frozen-lockfile | |
- run: yarn aos:build | |
- run: yarn test | |
publish: | |
runs-on: ubuntu-latest | |
needs: [unit, integration] | |
if: github.ref == 'refs/heads/main' | |
outputs: | |
publish-output: ${{ steps.set-publish-output.outputs.publish-output }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/[email protected] | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'yarn' | |
- run: yarn --frozen-lockfile | |
- run: yarn aos:build | |
id: publish-lua-code | |
- run: yarn aos:publish | |
env: | |
ARWEAVE_PUBLISHING_KEY: ${{ secrets.ARWEAVE_PUBLISHING_KEY }} | |
- name: Capture Publish Output | |
id: set-publish-output | |
run: | | |
publish_output=$(node -e "const fs = require('fs'); const output = JSON.parse(fs.readFileSync('tools/publish-output.json', 'utf-8')); console.log(output);") | |
echo "::set-output name=publish-output::$publish_output" | |
# Add the following steps to commit and push the changelog file and create a tag | |
- name: Commit and Push Changelog | |
run: | | |
prettier --write changelogs/*.md | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add changelogs/*.md | |
git commit -m "feat(publish): create changelog for ${{ fromJson(steps.set-publish-output.outputs.publish-output).luaCodeTxId }}" | |
git push origin HEAD | |
git tag -a ${{ fromJson(steps.set-publish-output.outputs.publish-output).luaCodeTxId }} | |
git push origin ${{ fromJson(steps.set-publish-output.outputs.publish-output).luaCodeTxId }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
notify: | |
runs-on: ubuntu-latest | |
needs: [unit, integration, publish] | |
if: always() | |
steps: | |
- name: Notify Slack on Success | |
if: github.ref == 'refs/heads/main' && needs.unit.result == 'success' && needs.integration.result == 'success' && (needs.publish.result == 'success' || needs.publish.result == 'skipped') | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
text: | | |
Unit Tests: ${{ needs.unit.result }} | |
Integration Tests: ${{ needs.integration.result }} | |
Published Lua Id: ${{ fromJson(needs.publish.outputs.publish-output).luaCodeTxId }} | |
Publisher Address: ${{ fromJson(needs.publish.outputs.publish-output).publisherAddress }} | |
Changelog: ${{ format('```{0}```', fromJson(needs.publish.outputs.publish-output).changelog) }} | |
fields: repo,message,commit,author,action,eventName,ref,workflow,job | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
- name: Notify Slack on Failure | |
if: failure() | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
text: | | |
Unit Tests: ${{ needs.unit.result }} | |
Integration Tests: ${{ needs.integration.result }} | |
fields: repo,message,commit,author,action,eventName,ref,workflow,job | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |