Generator #154
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: "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) | |
- rust | |
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: '' | |
VENDORDIR: | |
description: "(optional) golang vendor.tar.xz, input S in ebuild: Xray-core-24.11.11" | |
default: '' | |
jobs: | |
Generator: | |
permissions: write-all # required by push tag | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/peeweep/gentoo-testing:master | |
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 --global --add safe.directory '*' | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global 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: Setup rust | |
if: inputs.LANG == 'rust' | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
- name: Generate rust crates | |
if: inputs.LANG == 'rust' | |
env: | |
P: ${{ inputs.P }} | |
WORKDIR: ${{ inputs.WORKDIR }} | |
run: | | |
git tag ${P} -m "${P}-crates.tar.xz" | |
cd "input/${WORKDIR}" | |
pycargoebuild -c | |
- 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 node_modules 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) node_modules 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 }} | |
- name: upload rust crates to release artifaces | |
if: inputs.LANG == 'rust' | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
/var/cache/distfiles/${{ inputs.P }}-crates.tar.xz | |
input/${{ inputs.WORKDIR }}/${{ inputs.P }}.ebuild | |
tag_name: ${{ inputs.P }} |