Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9dc5fd673d | |||
| 125b06734a |
@@ -2,11 +2,10 @@ name: CI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, dev, uat]
|
branches: ['**']
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, dev, uat]
|
branches: [main, dev, uat]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
workflow_call:
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|||||||
@@ -4,77 +4,20 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
description: 'Release version (e.g. 1.0.1)'
|
description: 'Release version (e.g. 1.0.0)'
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
uses: privilegedescalation/.github/.github/workflows/plugin-release.yaml@main
|
||||||
|
secrets:
|
||||||
steps:
|
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
|
||||||
- name: Checkout
|
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
||||||
uses: actions/checkout@v4
|
with:
|
||||||
|
version: ${{ inputs.version }}
|
||||||
- name: Setup Node
|
upstream-repo: 'FairwindsOps/polaris'
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
cache: 'pnpm'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: pnpm install --frozen-lockfile
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: pnpm run build
|
|
||||||
|
|
||||||
- name: Get tarball path
|
|
||||||
id: tarball
|
|
||||||
run: |
|
|
||||||
# headlamp-plugin package outputs the tarball path, e.g.:
|
|
||||||
# "Packaged: /path/to/headlamp-polaris-1.0.0.tgz"
|
|
||||||
output=$(pnpm run package 2>&1)
|
|
||||||
echo "output=$output"
|
|
||||||
# Extract tarball name, e.g. headlamp-polaris-1.0.0.tgz
|
|
||||||
tarball_name=$(echo "$output" | grep -oP 'headlamp-polaris-\d+\.\d+\.\d+\.tgz' | tail -1)
|
|
||||||
echo "tarball_name=$tarball_name" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Create Gitea Release
|
|
||||||
env:
|
|
||||||
GITEA_URL: https://git.farh.net
|
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
REPO: privilegedescalation/headlamp-polaris-plugin
|
|
||||||
run: |
|
|
||||||
VERSION="${{ inputs.version }}"
|
|
||||||
ASSET_NAME="headlamp-polaris-${VERSION}.tar.gz"
|
|
||||||
|
|
||||||
# Create the release via Gitea API
|
|
||||||
RELEASE_RESPONSE=$(
|
|
||||||
curl -s -X POST \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases" \
|
|
||||||
-d "{
|
|
||||||
\"tag_name\": \"v${VERSION}\",
|
|
||||||
\"name\": \"v${VERSION}\",
|
|
||||||
\"draft\": false,
|
|
||||||
\"prerelease\": false
|
|
||||||
}"
|
|
||||||
)
|
|
||||||
echo "Release response: ${RELEASE_RESPONSE}"
|
|
||||||
|
|
||||||
RELEASE_ID=$(echo "${RELEASE_RESPONSE}" | python3 -c "import sys, json; print(json.load(sys.stdin).get('id', ''))")
|
|
||||||
if [ -z "$RELEASE_ID" ]; then
|
|
||||||
echo "Failed to create release"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Upload the tarball asset
|
|
||||||
curl -s -X POST \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
|
||||||
-T "${{ steps.tarball.outputs.tarball_name }}" \
|
|
||||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${ASSET_NAME}"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user