Archived
ci: migrate workflows and dependencies to Gitea Actions
This commit is contained in:
3 files changed
+89
-53
No files matched your search
@@ -0,0 +1,35 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
import uuid
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
import urllib.request
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
server = 'https://git.ermnvldmr.com/api/v1/repos/' + os.environ['GITHUB_REPOSITORY']
|
||||||
|
headers = {'Authorization': 'token ' + os.environ['RELEASE_TOKEN']}
|
||||||
|
tag = os.environ['GITHUB_REF_NAME']
|
||||||
|
|
||||||
|
|
||||||
|
def request(path, data=None, content_type=None):
|
||||||
|
current = headers.copy()
|
||||||
|
if content_type:
|
||||||
|
current['Content-Type'] = content_type
|
||||||
|
req = urllib.request.Request(server + path, data=data, headers=current)
|
||||||
|
with urllib.request.urlopen(req, timeout=120) as response:
|
||||||
|
return json.load(response)
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
release = request('/releases/tags/' + urllib.parse.quote(tag, safe=''))
|
||||||
|
except urllib.error.HTTPError as error:
|
||||||
|
if error.code != 404:
|
||||||
|
raise
|
||||||
|
release = request('/releases', json.dumps({'tag_name': tag, 'name': tag, 'draft': False}).encode(), 'application/json')
|
||||||
|
for artifact in sorted(Path('artifacts').glob('*')):
|
||||||
|
if not artifact.is_file():
|
||||||
|
continue
|
||||||
|
boundary = uuid.uuid4().hex
|
||||||
|
filename = artifact.name.replace('"', '_').replace('\r', '_').replace('\n', '_')
|
||||||
|
body = (f'--{boundary}\r\nContent-Disposition: form-data; name="attachment"; filename="{filename}"\r\nContent-Type: application/octet-stream\r\n\r\n'.encode() + artifact.read_bytes() + f'\r\n--{boundary}--\r\n'.encode())
|
||||||
|
request('/releases/' + str(release['id']) + '/assets?name=' + urllib.parse.quote(filename), body, 'multipart/form-data; boundary=' + boundary)
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
name: actions
|
||||||
|
'on':
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*.*.*
|
||||||
|
jobs:
|
||||||
|
pkg:
|
||||||
|
runs-on: apex-debian13
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version:
|
||||||
|
- 18.x
|
||||||
|
pnpm-version:
|
||||||
|
- 8
|
||||||
|
steps:
|
||||||
|
- name: Check out the repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
run: |
|
||||||
|
case "$NODE_VERSION" in
|
||||||
|
18*) major=18;; 20*) major=20;; 22*) major=22;; *) exit 1;;
|
||||||
|
esac
|
||||||
|
test -x "/opt/ci/node/$major/bin/node"
|
||||||
|
echo "/opt/ci/node/$major/bin" >> "$GITHUB_PATH"
|
||||||
|
env:
|
||||||
|
NODE_VERSION: ${{ matrix.node-version }}
|
||||||
|
- name: Install PKG
|
||||||
|
run: |
|
||||||
|
test -x /opt/ci/pkg/bin/pkg
|
||||||
|
echo /opt/ci/pkg/bin >> "$GITHUB_PATH"
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: ESLint & Prettier
|
||||||
|
run: npm run lint
|
||||||
|
- name: Build
|
||||||
|
run: npm run build
|
||||||
|
- name: Test
|
||||||
|
run: npm run --if-present test
|
||||||
|
- name: Package
|
||||||
|
run: pkg --out-path ./artifacts ./dist/index.js
|
||||||
|
- name: Naming
|
||||||
|
run: |
|
||||||
|
for f in ./artifacts/index*; do
|
||||||
|
mv -i -- "$f" "${f//index/styleforces}"
|
||||||
|
done
|
||||||
|
- name: Release
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: python3 .gitea/scripts/release.py
|
||||||
|
env:
|
||||||
|
RELEASE_TOKEN: ${{ github.token }}
|
||||||
|
env:
|
||||||
|
PKG_CACHE_PATH: /opt/ci/pkg-cache
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
name: actions
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- "v*.*.*"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
pkg:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [18.x]
|
|
||||||
pnpm-version: [8]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check out the repo
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
|
|
||||||
- name: Install PKG
|
|
||||||
run: npm install -g pkg
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm install
|
|
||||||
|
|
||||||
- name: ESLint & Prettier
|
|
||||||
run: npm run lint
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: npm run build
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
run: npm run --if-present test
|
|
||||||
|
|
||||||
- name: Package
|
|
||||||
run: pkg --out-path ./artifacts ./dist/index.js
|
|
||||||
|
|
||||||
- name: Naming
|
|
||||||
run: for f in ./artifacts/index*; do mv -i -- "$f" "${f//index/styleforces}"; done
|
|
||||||
|
|
||||||
- name: Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
with:
|
|
||||||
files: |
|
|
||||||
artifacts/*
|
|
||||||
|
|
||||||
Reference in new issue
Block a user