Skip to content

Generator

Generator #120

Workflow file for this run

name: "Generator"
on:
workflow_dispatch:
inputs:
# https://github.com/XTLS/Xray-core v24.11.11
# net-proxy/Xray/Xray-24.11.11.ebuild
# release artiface: ${PN}-${PV}-deps.tar.xz: Xray-24.11.11-deps.tar.xz
# release tag: ${P}=${PN}-${PV}: Xray-24.11.11
LANG:
type: choice
description: "generate golang(go-mod/vendor) or javascript(node_modules) deps"
options:
- golang
- javascript
- javascript(pnpm)
REPO:
description: "github repo name: XTLS/Xray-core"
required: true
TAG:
description: "github tag: v24.11.11"
required: true
P:
description: "P in ebuild: Xray-24.11.11"
required: true
WORKDIR:
description: "(optional) source directory to perform scripts, default to empty string"
default: ''
VENDORDIR:
description: "(optional) generate vendor.tar.xz, input the S in ebuild here: Xray-core-24.11.11, disabled default"
default: ''
jobs:
Generator:
permissions: write-all # required by push tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout input repo
uses: actions/checkout@v4
with:
repository: ${{ inputs.REPO }}
ref: ${{ inputs.TAG }}
fetch-depth: 0
path: "input"
- name: delete old tag
env:
P: ${{ inputs.P }}
LANG: ${{ inputs.LANG }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git tag --delete ${P} || echo yes
- name: update go version
if: inputs.LANG == 'golang'
uses: actions/setup-go@v5
with:
go-version: 'stable'
cache: false
- name: Generate golang deps
if: inputs.LANG == 'golang'
env:
P: ${{ inputs.P }}
WORKDIR: ${{ inputs.WORKDIR }}
VENDORDIR: ${{ inputs.VENDORDIR }}
run: |
git tag ${P} -m "${P}-deps.tar.xz ${P}-vendor.tar.xz"
cd "input/${WORKDIR}"
GOMODCACHE="${PWD}"/go-mod go mod download -modcacherw
tar --create --auto-compress --file /tmp/${P}-deps.tar.xz go-mod
if [[ ! -f go.work && x"${VENDORDIR}" != x"" ]]; then
rm -rf go-mod
go mod vendor -modcacherw -o ${VENDORDIR}/vendor
tar --create --auto-compress --file /tmp/${P}-vendor.tar.xz ${VENDORDIR}/vendor
fi
- name: Generate javascript node_modules
if: inputs.LANG == 'javascript'
env:
P: ${{ inputs.P }}
WORKDIR: ${{ inputs.WORKDIR }}
run: |
git tag ${P} -m "${P}-node_modules.tar.xz"
cd "input/${WORKDIR}"
npm install --legacy-peer-deps --cache "${PWD}"/npm-cache
tar --create --auto-compress --file /tmp/${P}-node_modules.tar.xz node_modules
rm -rf node_modules
- name: Setup pnpm
if: inputs.LANG == 'javascript(pnpm)'
uses: pnpm/action-setup@v4
with:
version: latest
- name: Generate javascript(pnpm) node_modules
if: inputs.LANG == 'javascript(pnpm)'
env:
P: ${{ inputs.P }}
WORKDIR: ${{ inputs.WORKDIR }}
run: |
git tag ${P} -m "${P}-node_modules-pnpm.tar.xz"
cd "input/${WORKDIR}"
pnpm install
tar --create --auto-compress --file /tmp/${P}-node_modules-pnpm.tar.xz node_modules
rm -rf node_modules
- name: push tag
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
tags: true
- name: upload golang deps to release artifaces
if: inputs.LANG == 'golang'
uses: softprops/action-gh-release@v2
with:
files: |
/tmp/${{ inputs.P }}-deps.tar.xz
tag_name: ${{ inputs.P }}
- name: upload golang vendor to release artifaces
if: inputs.LANG == 'golang' && inputs.VENDORDIR != ''
uses: softprops/action-gh-release@v2
with:
files: |
/tmp/${{ inputs.P }}-vendor.tar.xz
tag_name: ${{ inputs.P }}
- name: upload javascript deps to release artifaces
if: inputs.LANG == 'javascript'
uses: softprops/action-gh-release@v2
with:
files: |
/tmp/${{ inputs.P }}-node_modules.tar.xz
tag_name: ${{ inputs.P }}
- name: upload javascript(pnpm) deps to release artifaces
if: inputs.LANG == 'javascript(pnpm)'
uses: softprops/action-gh-release@v2
with:
files: |
/tmp/${{ inputs.P }}-node_modules-pnpm.tar.xz
tag_name: ${{ inputs.P }}