Improve workflows

This commit is contained in:
twnesss
2024-10-29 01:48:38 +07:00
parent 50c22861ad
commit f271c48c14
4 changed files with 27 additions and 132 deletions

View File

@@ -19,23 +19,16 @@ jobs:
with:
fetch-depth: 0
- name: Get tags
id: get_tags
- name: Update Module.prop
run: |
echo "tag=$(grep -oP 'version=\K[^ ]+' module.prop)" >> "$GITHUB_OUTPUT"
echo "version=$(git rev-parse --short HEAD)_$(date +%Y%m%d)" >> "$GITHUB_OUTPUT"
echo "versionCode=$(date +%Y%m%d)" >> "$GITHUB_OUTPUT"
sed -i "s/$(grep -oP 'version=\K[^ ]+' module.prop)/$(cat module.prop | grep 'version=' | awk -F '=' '{print $2}')($(git log --oneline -n 1 | awk '{print $1}'))/g" module.prop
sed -i "s/versionCode=.*/versionCode=$(date +%Y%m%d)/g" module.prop
- name: update module.prop
run: |
sed -i "s/${{ steps.get_tags.outputs.tag }}/&_${{ steps.get_tags.outputs.version }}_debug/g" module.prop
sed -i "s/versionCode=.*/versionCode=${{ steps.get_tags.outputs.versionCode }}/g" module.prop
- name: get version
- name: Get Version
id: get_version
run: |
echo "version=$(grep -oP 'version=\K[^ ]+' module.prop)" >> "$GITHUB_OUTPUT"
- name: Generate Asset
run: |
sudo mkdir -p /box_for_root
@@ -47,41 +40,25 @@ jobs:
name: "box_for_magisk_${{ steps.get_version.outputs.version }}"
path: /box_for_root/
upload:
name: Telegram Upload Release
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4.1.0
with:
fetch-depth: 0
# - name: Download Debug Asset => (box_for_magisk_${{ steps.get_version.outputs.version }})
# uses: actions/download-artifact@v4
# with:
# name: "box_for_magisk_${{ steps.get_version.outputs.version }}"
# path: /box_for_root/
- name: Get tags
id: get_tags
run: |
echo "tag=$(grep -oP 'version=\K[^ ]+' module.prop)" >> "$GITHUB_OUTPUT"
echo "version=$(git rev-parse --short HEAD)_$(date +%Y%m%d)" >> "$GITHUB_OUTPUT"
echo "versionCode=$(date +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Get Version and Build
run: |
sed -i "s/${{ steps.get_tags.outputs.tag }}/&_${{ steps.get_tags.outputs.version }}_debug/g" module.prop
sed -i "s/versionCode=.*/versionCode=${{ steps.get_tags.outputs.versionCode }}/g" module.prop
sh build.sh
- name: upload to telegram
if: ${{ success() }}
env:
CHAT_ID: "-1001597117128"
MESSAGE_THREAD_ID: "282263"
API_ID: ${{ secrets.API_ID }}
API_HASH: ${{ secrets.API_HASH }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
export VERSION=${{ steps.get_tags.outputs.tag }}_${{ steps.get_tags.outputs.version }}
export COMMIT=$(git log --oneline -n 10 --no-decorate | sed 's/^[0-9a-f]* //' | sed 's/^/— /')
FILE=$(find -name "*.zip")
pip3 install telethon==1.31.1
python3 $GITHUB_WORKSPACE/.github/taamarinbot.py $FILE
fi
# - name: Upload To Telegram
# if: ${{ success() }}
# env:
# CHAT_ID: "-1001597117128"
# MESSAGE_THREAD_ID: "282263"
# API_ID: ${{ secrets.API_ID }}
# API_HASH: ${{ secrets.API_HASH }}
# BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
# run: |
# if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
# export VERSION=${{ steps.get_version.outputs.version }}
# export COMMIT=$(git log --oneline -n 10 --no-decorate | sed 's/^[0-9a-f]* //' | sed 's/^/— /')
# FILE=$(find -name "*.zip")
# pip3 install telethon==1.31.1
# python3 $GITHUB_WORKSPACE/.github/taamarinbot.py $FILE
# fi

View File

@@ -1,17 +0,0 @@
name: Delete old workflow runs
on:
workflow_dispatch:
jobs:
delete_old_runs:
runs-on: ubuntu-latest
steps:
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
if: github.ref == 'refs/heads/master'
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
retain_days: 0
keep_minimum_runs: 5

View File

@@ -1,66 +0,0 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow lets you generate SLSA provenance file for your project.
# The generation satisfies level 3 for the provenance requirements - see https://slsa.dev/spec/v0.1/requirements
# The project is an initiative of the OpenSSF (openssf.org) and is developed at
# https://github.com/slsa-framework/slsa-github-generator.
# The provenance file can be verified using https://github.com/slsa-framework/slsa-verifier.
# For more information about SLSA and how it improves the supply-chain, visit slsa.dev.
name: SLSA generic generator
on:
workflow_dispatch:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
outputs:
digests: ${{ steps.hash.outputs.digests }}
steps:
- uses: actions/checkout@v4
# ========================================================
#
# Step 1: Build your artifacts.
#
# ========================================================
- name: Build artifacts
run: |
# These are some amazing artifacts.
echo "artifact1" > artifact1
echo "artifact2" > artifact2
# ========================================================
#
# Step 2: Add a step to generate the provenance subjects
# as shown below. Update the sha256 sum arguments
# to include all binaries that you generate
# provenance for.
#
# ========================================================
- name: Generate subject for provenance
id: hash
run: |
set -euo pipefail
# List the artifacts the provenance will refer to.
files=$(ls artifact*)
# Generate the subjects (base64 encoded).
echo "hashes=$(sha256sum $files | base64 -w0)" >> "${GITHUB_OUTPUT}"
provenance:
needs: [build]
permissions:
actions: read # To read the workflow path.
id-token: write # To sign the provenance.
contents: write # To add assets to a release.
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.4.0
with:
base64-subjects: "${{ needs.build.outputs.digests }}"
upload-assets: true # Optional: Upload to a new release