Skip to content

enhance: add readable log #13

enhance: add readable log

enhance: add readable log #13

Workflow file for this run

name: "publish"
on:
pull_request:
types:
- opened
branches:
- 'main'
- 'releases/**'
paths:
- '**.rs'
jobs:
create-release:
permissions:
contents: write
runs-on: ubuntu-20.04
outputs:
release_id: ${{ steps.create-release.outputs.result }}
steps:
- uses: actions/checkout@v4
- name: get version
uses: SebRollen/toml-action@v1.2.0
id: read_toml
with:
file: "Cargo.toml"
field: "package.version"
- name: create release
id: create-release
uses: actions/github-script@v7
with:
script: |
const { data } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `athene_network_bot_v${{steps.read_toml.outputs.value}}`,
name: `Athene Bot v${{steps.read_toml.outputs.value}}`,
body: `${{ github.event.head_commit.message }}`,
draft: true,
prerelease: false
})
return data.id
build-app:
needs: create-release
permissions:
contents: write
strategy:
matrix:
build: [linux, macos, windows]
include:
- build: linux
os: ubuntu-22.04
rust: nightly
target: x86_64-unknown-linux-gnu
archive-name: athene-bot-linux.tar.gz
- build: macos
os: macos-latest
rust: nightly
target: x86_64-apple-darwin
archive-name: athene-bot-macos.tar.gz
- build: windows
os: windows-latest
rust: nightly-x86_64-msvc
target: x86_64-pc-windows-msvc
archive-name: athene-bot-windows.7z
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: get name
uses: SebRollen/toml-action@v1.2.0
id: read_toml
with:
file: "Cargo.toml"
field: "package.name"
- name: Install Rust
uses: actions-rs/toolchain@v1.0.6
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Install libssl-dev
shell: bash
run: |
if [ "${{ matrix.build }}" = "linux" ]; then
sudo apt-get install -y pkg-config libssl-dev
fi
- name: Build binary
run: cargo build --verbose --release --target ${{ matrix.target }}
env:
RUST_BACKTRACE: 1
- name: Build archive
shell: bash
run: |
mkdir archive
cp LICENSE README.md archive/
cd archive
if [ "${{ matrix.build }}" = "windows" ]; then
cp "../target/${{ matrix.target }}/release/${{steps.read_toml.outputs.value}}.exe" ./
7z a "${{ matrix.archive-name }}" LICENSE README.md ${{steps.read_toml.outputs.value}}.exe
else
cp "../target/${{ matrix.target }}/release/${{steps.read_toml.outputs.value}}" ./
tar -czf "${{ matrix.archive-name }}" LICENSE README.md ${{steps.read_toml.outputs.value}}
fi
ls -a
- name: upload release asset
uses: actions/github-script@v7
env:
release_id: ${{ needs.create-release.outputs.release_id }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('node:fs')
github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id,
name: '${{ matrix.archive-name }}',
data: await fs.readFileSync('./archive/${{ matrix.archive-name }}'),
})
# - name: Upload archive
# uses: actions/upload-artifact@v1
# with:
# name: ${{ matrix.archive-name }}
# path: archive/${{ matrix.archive-name }}
publish-release:
permissions:
contents: write
runs-on: ubuntu-20.04
needs: [create-release, build-app]
steps:
- name: publish release
id: publish-release
uses: actions/github-script@v7
env:
release_id: ${{ needs.create-release.outputs.release_id }}
with:
script: |
github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id,
draft: false,
prerelease: false
})