afterCI change release #47
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: afterCI change release | |
on: | |
# workflow_run: | |
# workflows: ["Sillot CI/CD"] | |
# types: | |
# - completed | |
workflow_dispatch: | |
release: | |
types: [released] | |
# https://docs.github.com/zh/actions/using-workflows/events-that-trigger-workflows#release | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
name: afterCI action | |
steps: | |
- name: Get Latest Release Assets | |
id: latest_release | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
retries: 3 | |
debug: true | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const { execSync } = require('child_process'); | |
const { data } = await github.rest.repos.getLatestRelease({owner: 'Hi-Windom',repo: 'Sillot'}); | |
// const d = JSON.stringify(data); | |
// console.log(d) | |
data.assets.forEach(async (e) => { console.log(e.browser_download_url); execSync(`curl -LO ${e.browser_download_url}`); }) | |
return data.upload_url | |
continue-on-error: false | |
- name: Generate Hash for Assets | |
id: generate_hash | |
# 使用了 awk 的内置函数 toupper() 来将哈希值转换为大写,同时使用空格作为字段分隔符。awk 会将每一行的第一个字段(哈希值)转换为大写,并且保留第二个字段(文件名) | |
run: | | |
ls | |
find . -type f -name 'Sillot-*' -exec md5sum {} + | awk '{print toupper($1), $2}' > Assets_MD5_Sum.txt | |
find . -type f -name 'Sillot-*' -exec sha256sum {} + | awk '{print toupper($1), $2}' > Assets_SHA256_Sum.txt | |
continue-on-error: false | |
- name: Upload Assets_MD5_Sum.txt File to Release Asset | |
uses: shogo82148/actions-upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.latest_release.outputs.result }} | |
asset_path: ./Assets_MD5_Sum.txt | |
asset_name: Assets_MD5_Sum.txt | |
- name: Upload Assets_SHA256_Sum.txt File to Release Asset | |
uses: shogo82148/actions-upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.latest_release.outputs.result }} | |
asset_path: ./Assets_SHA256_Sum.txt | |
asset_name: Assets_SHA256_Sum.txt |