Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JesuisTong committed Sep 8, 2024
2 parents 5cb35eb + 48907a8 commit 7a83c98
Show file tree
Hide file tree
Showing 7 changed files with 306 additions and 61 deletions.
59 changes: 43 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: "publish"

on:
push:
on:
pull_request:
types:
- opened
branches:
- 'main'
- 'releases/**'
paths:
- '**.rs'

jobs:
create-release:
Expand All @@ -26,15 +30,15 @@ jobs:

- name: create release
id: create-release
uses: actions/github-script@v6
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: 'Take a look at the assets to download and install this app.',
body: `${{ github.event.head_commit.message }}`,
draft: true,
prerelease: false
})
Expand All @@ -49,42 +53,49 @@ jobs:
build: [linux, macos, windows]
include:
- build: linux
os: ubuntu-18.04
os: ubuntu-22.04
rust: nightly
target: x86_64-unknown-linux-musl
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-2019
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.platform }}
runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: get version
- name: get name
uses: SebRollen/[email protected]
id: read_toml
with:
file: "Cargo.toml"
field: "package.name"

- name: Install Rust
uses: actions-rs/toolchain@v1
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:
Expand All @@ -103,11 +114,27 @@ jobs:
cp "../target/${{ matrix.target }}/release/${{steps.read_toml.outputs.value}}" ./
tar -czf "${{ matrix.archive-name }}" LICENSE README.md ${{steps.read_toml.outputs.value}}
fi
- name: Upload archive
uses: actions/upload-artifact@v1
ls -a
- name: upload release asset
uses: actions/github-script@v7
env:
release_id: ${{ needs.create-release.outputs.release_id }}
with:
name: ${{ matrix.archive-name }}
path: archive/${{ matrix.archive-name }}
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:
Expand All @@ -118,7 +145,7 @@ jobs:
steps:
- name: publish release
id: publish-release
uses: actions/github-script@v6
uses: actions/github-script@v7
env:
release_id: ${{ needs.create-release.outputs.release_id }}
with:
Expand Down
Loading

0 comments on commit 7a83c98

Please sign in to comment.