Some checks are pending
Build and Deploy React Package / build-and-publish (push) Waiting to run
113 lines
3.9 KiB
YAML
113 lines
3.9 KiB
YAML
name: Build and Deploy React Package
|
|
|
|
# Controls when the workflow will run. Here, it runs on every push to the 'main' branch.
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
|
|
# Environment variables used across the workflow
|
|
env:
|
|
# The URL of your Gitea instance (without http:// or https://)
|
|
GITEA_INSTANCE_URL: git.deowl.ru
|
|
# The full name of your package (e.g., 'myusername/myproject')
|
|
PACKAGE_NAME: vkrb/quantum_frontend
|
|
# Node.js version to use
|
|
NODE_VERSION: "25.9.0"
|
|
|
|
jobs:
|
|
build-and-publish:
|
|
# Runs the job on a runner with the 'ubuntu-latest' label.
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# 1. Check out your repository code so the workflow can access it.
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
# 2. Set up Node.js environment
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
# 3. Install pnpm globally
|
|
- name: Install pnpm
|
|
run: npm install -g pnpm
|
|
|
|
# 4. Install dependencies with pnpm
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
# 5. Build the React/Vite application
|
|
# This assumes your vite.config.js/ts is configured to output to 'dist'
|
|
- name: Build application
|
|
run: pnpm run build
|
|
|
|
# 6. Create a tarball of the build artifacts
|
|
- name: Create package tarball
|
|
run: |
|
|
# Create a directory for the package
|
|
mkdir -p package_artifact
|
|
|
|
# Copy build artifacts (adjust path if your build outputs to a different directory)
|
|
cp -r dist package_artifact/
|
|
|
|
# Optionally copy other important files
|
|
# cp package.json package_artifact/
|
|
# cp README.md package_artifact/
|
|
|
|
# Create tarball
|
|
tar -czf package.tar.gz -C package_artifact .
|
|
|
|
# Generate checksum for integrity
|
|
sha256sum package.tar.gz > package.tar.gz.sha256
|
|
|
|
# 7. Log in to Gitea Package Registry
|
|
- name: Log in to Gitea Package Registry
|
|
run: |
|
|
# Create .netrc file for authentication with Gitea
|
|
cat > ~/.netrc << EOF
|
|
machine ${{ env.GITEA_INSTANCE_URL }}
|
|
login ${{ gitea.repository_owner }}
|
|
password ${{ secrets.REGISTRY_TOKEN }}
|
|
EOF
|
|
|
|
# 8. Upload the package to Gitea Generic Package Registry
|
|
- name: Upload to Gitea Generic Package Registry
|
|
run: |
|
|
# The format for Gitea generic packages:
|
|
# https://{GITEA_INSTANCE_URL}/api/packages/{owner}/generic/{package-name}/{version}/{file-name}
|
|
|
|
# Generate version from git commit SHA and timestamp
|
|
VERSION="${{ gitea.sha }}"
|
|
|
|
# Upload the tarball
|
|
curl --fail-with-body \
|
|
--netrc \
|
|
--upload-file package.tar.gz \
|
|
"https://${{ env.GITEA_INSTANCE_URL }}/api/packages/${{ gitea.repository_owner }}/generic/${{ env.PACKAGE_NAME }}/${VERSION}/package.tar.gz"
|
|
|
|
# Upload the checksum file
|
|
curl --fail-with-body \
|
|
--netrc \
|
|
--upload-file package.tar.gz.sha256 \
|
|
"https://${{ env.GITEA_INSTANCE_URL }}/api/packages/${{ gitea.repository_owner }}/generic/${{ env.PACKAGE_NAME }}/${VERSION}/package.tar.gz.sha256"
|
|
|
|
# 9. (Optional) Create a latest version for convenience
|
|
- name: Update latest version
|
|
run: |
|
|
# Upload as 'latest' version
|
|
curl --fail-with-body \
|
|
--netrc \
|
|
--upload-file package.tar.gz \
|
|
"https://${{ env.GITEA_INSTANCE_URL }}/api/packages/${{ gitea.repository_owner }}/generic/${{ env.PACKAGE_NAME }}/latest/package.tar.gz"
|
|
|
|
curl --fail-with-body \
|
|
--netrc \
|
|
--upload-file package.tar.gz.sha256 \
|
|
"https://${{ env.GITEA_INSTANCE_URL }}/api/packages/${{ gitea.repository_owner }}/generic/${{ env.PACKAGE_NAME }}/latest/package.tar.gz.sha256"
|
|
|
|
# 10. Clean up
|
|
- name: Clean up
|
|
run: rm -f package.tar.gz package.tar.gz.sha256
|