Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
009ca1c607 | ||
|
|
5a1827ae4c |
@@ -8,16 +8,47 @@ on:
|
|||||||
NodeVersion:
|
NodeVersion:
|
||||||
required: true
|
required: true
|
||||||
description: 'Node.js version to build (ex: v12.22.7, v16.12.0)'
|
description: 'Node.js version to build (ex: v12.22.7, v16.12.0)'
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
NodeVersion:
|
||||||
|
required: true
|
||||||
|
description: 'Node.js version to build (ex: v12.22.7, v16.12.0)'
|
||||||
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
prebuild:
|
||||||
|
outputs:
|
||||||
|
NodeVersion: ${{ steps.check_node_version.outputs.NodeVersion }}
|
||||||
|
name: Determine node.js version
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check node.js version
|
||||||
|
id: check_node_version
|
||||||
|
run: |
|
||||||
|
# Determine which NodeVersion input to use
|
||||||
|
if [ -n "${{ github.event.inputs.NodeVersion }}" ]; then
|
||||||
|
NODE_VERSION="${{ github.event.inputs.NodeVersion }}"
|
||||||
|
echo "Using NodeVersion from workflow_dispatch: $NODE_VERSION"
|
||||||
|
elif [ -n "${{ inputs.NodeVersion }}" ]; then
|
||||||
|
NODE_VERSION="${{ inputs.NodeVersion }}"
|
||||||
|
echo "Using NodeVersion from workflow_call: $NODE_VERSION"
|
||||||
|
else
|
||||||
|
echo "Error: No NodeVersion specified"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set the output that will be used by subsequent steps/jobs
|
||||||
|
echo "NodeVersion=$NODE_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build node.js ${{github.event.inputs.NodeVersion}}
|
needs: [prebuild]
|
||||||
|
name: Build node.js ${{needs.prebuild.outputs.NodeVersion}}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Build the Docker image
|
- name: Build the Docker image
|
||||||
run: |
|
run: |
|
||||||
NodeVersion="${{github.event.inputs.NodeVersion}}"
|
NodeVersion="${{needs.prebuild.outputs.NodeVersion}}"
|
||||||
PythonVersion="python3"
|
PythonVersion="python3"
|
||||||
if [[ $NodeVersion = v12* ]]
|
if [[ $NodeVersion = v12* ]]
|
||||||
then
|
then
|
||||||
@@ -25,31 +56,31 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
echo node.js version $NodeVersion
|
echo node.js version $NodeVersion
|
||||||
echo python version $PythonVersion
|
echo python version $PythonVersion
|
||||||
docker build --file Dockerfile --tag alpine_nodejs:${{github.event.inputs.NodeVersion}} --build-arg NodeVersion=${{github.event.inputs.NodeVersion}} --build-arg PythonVersion=$PythonVersion .
|
docker build --file Dockerfile --tag alpine_nodejs:${{needs.prebuild.outputs.NodeVersion}} --build-arg NodeVersion=${{needs.prebuild.outputs.NodeVersion}} --build-arg PythonVersion=$PythonVersion .
|
||||||
- name: Copy alpine node.js out
|
- name: Copy alpine node.js out
|
||||||
run: |
|
run: |
|
||||||
mkdir $RUNNER_TEMP/alpine_node
|
mkdir $RUNNER_TEMP/alpine_node
|
||||||
docker run --rm -v $RUNNER_TEMP/alpine_node:/node_output alpine_nodejs:${{github.event.inputs.NodeVersion}}
|
docker run --rm -v $RUNNER_TEMP/alpine_node:/node_output alpine_nodejs:${{needs.prebuild.outputs.NodeVersion}}
|
||||||
ls -l -R $RUNNER_TEMP/alpine_node
|
ls -l -R $RUNNER_TEMP/alpine_node
|
||||||
- name: Upload alpine node.js
|
- name: Upload alpine node.js
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}
|
name: alpine_nodejs_${{needs.prebuild.outputs.NodeVersion}}
|
||||||
path: ${{runner.temp}}/alpine_node/node-${{github.event.inputs.NodeVersion}}-alpine-x64.tar.gz
|
path: ${{runner.temp}}/alpine_node/node-${{needs.prebuild.outputs.NodeVersion}}-alpine-x64.tar.gz
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Test node.js ${{github.event.inputs.NodeVersion}}
|
name: Test node.js ${{needs.prebuild.outputs.NodeVersion}}
|
||||||
needs: [build]
|
needs: [prebuild, build]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: alpine
|
container: alpine
|
||||||
steps:
|
steps:
|
||||||
- name: Download alpine node.js
|
- name: Download alpine node.js
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}
|
name: alpine_nodejs_${{needs.prebuild.outputs.NodeVersion}}
|
||||||
- run: |
|
- run: |
|
||||||
ls -l
|
ls -l
|
||||||
tar xzf ./node-${{github.event.inputs.NodeVersion}}-alpine-x64.tar.gz
|
tar xzf ./node-${{needs.prebuild.outputs.NodeVersion}}-alpine-x64.tar.gz
|
||||||
ls -l -R
|
ls -l -R
|
||||||
./bin/node -v
|
./bin/node -v
|
||||||
./bin/node -e "console.log('hello world')"
|
./bin/node -e "console.log('hello world')"
|
||||||
@@ -57,25 +88,25 @@ jobs:
|
|||||||
ldd ./bin/node
|
ldd ./bin/node
|
||||||
name: Test node
|
name: Test node
|
||||||
release:
|
release:
|
||||||
name: Create release for node.js ${{github.event.inputs.NodeVersion}}
|
name: Create release for node.js ${{needs.prebuild.outputs.NodeVersion}}
|
||||||
needs: [test]
|
needs: [prebuild, test]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Download alpine node.js
|
- name: Download alpine node.js
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: alpine_nodejs_${{github.event.inputs.NodeVersion}}
|
name: alpine_nodejs_${{needs.prebuild.outputs.NodeVersion}}
|
||||||
# Create GitHub release
|
# Create GitHub release
|
||||||
- uses: actions/create-release@master
|
- uses: actions/create-release@master
|
||||||
id: createRelease
|
id: createRelease
|
||||||
name: Create node.js ${{github.event.inputs.NodeVersion}} Alpine Release
|
name: Create node.js ${{needs.prebuild.outputs.NodeVersion}} Alpine Release
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: "${{github.event.inputs.NodeVersion}}"
|
tag_name: "${{needs.prebuild.outputs.NodeVersion}}"
|
||||||
release_name: "${{github.event.inputs.NodeVersion}}"
|
release_name: "${{needs.prebuild.outputs.NodeVersion}}"
|
||||||
body: |
|
body: |
|
||||||
Alpine node.js ${{github.event.inputs.NodeVersion}}
|
Alpine node.js ${{needs.prebuild.outputs.NodeVersion}}
|
||||||
# Upload release assets
|
# Upload release assets
|
||||||
- name: Upload Release Asset
|
- name: Upload Release Asset
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
uses: actions/upload-release-asset@v1.0.1
|
||||||
@@ -83,6 +114,6 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.createRelease.outputs.upload_url }}
|
upload_url: ${{ steps.createRelease.outputs.upload_url }}
|
||||||
asset_path: ${{ github.workspace }}/node-${{github.event.inputs.NodeVersion}}-alpine-x64.tar.gz
|
asset_path: ${{ github.workspace }}/node-${{needs.prebuild.outputs.NodeVersion}}-alpine-x64.tar.gz
|
||||||
asset_name: node-${{github.event.inputs.NodeVersion}}-alpine-x64.tar.gz
|
asset_name: node-${{needs.prebuild.outputs.NodeVersion}}-alpine-x64.tar.gz
|
||||||
asset_content_type: application/octet-stream
|
asset_content_type: application/octet-stream
|
||||||
|
|||||||
80
.github/workflows/release-alpine-nodejs-on-schedule.yml
vendored
Normal file
80
.github/workflows/release-alpine-nodejs-on-schedule.yml
vendored
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
name: Build and Release Alpine Node.js on Schedule
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * 0' # Every Sunday at midnight
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
get_versions:
|
||||||
|
outputs:
|
||||||
|
versions: ${{ steps.set-matrix.outputs.versions }}
|
||||||
|
buildnode: ${{ steps.set-matrix.outputs.buildnode }}
|
||||||
|
name: Find versions to build and release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Find latest versions from each major version
|
||||||
|
id: set-matrix
|
||||||
|
run: |
|
||||||
|
BUILD_NODE=0
|
||||||
|
|
||||||
|
# Read major versions from versions.json
|
||||||
|
MAJOR_VERSIONS=$(jq -r '.[]' versions.json)
|
||||||
|
|
||||||
|
# Initialize array to store latest versions
|
||||||
|
LATEST_VERSIONS=()
|
||||||
|
|
||||||
|
# For each major version, find the latest release
|
||||||
|
for VERSION in $MAJOR_VERSIONS; do
|
||||||
|
# Get latest release for this major version
|
||||||
|
LATEST=$(curl -s "https://nodejs.org/dist/index.json" | \
|
||||||
|
jq -r "[.[] | select(.version | startswith(\"$VERSION.\"))] | sort_by(.date) | reverse | .[0].version")
|
||||||
|
|
||||||
|
if [ -n "$LATEST" ]; then
|
||||||
|
echo "Found latest $VERSION: $LATEST"
|
||||||
|
|
||||||
|
# Check if this version already exists in GitHub releases
|
||||||
|
# Using the GitHub API to check if the tag/release exists
|
||||||
|
RELEASE_EXISTS=$(curl -s -H "Authorization: token ${{github.token}}" \
|
||||||
|
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${LATEST}" | \
|
||||||
|
jq -r '.id != null')
|
||||||
|
|
||||||
|
if [ "$RELEASE_EXISTS" == "true" ]; then
|
||||||
|
echo "Release for $LATEST already exists - skipping"
|
||||||
|
else
|
||||||
|
echo "Release for $LATEST does not exist - will build"
|
||||||
|
LATEST_VERSIONS+=("$LATEST")
|
||||||
|
BUILD_NODE=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No version found for $VERSION"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Create properly escaped JSON for GitHub Actions
|
||||||
|
MATRIX_JSON=$(jq -c -n --argjson versions "$(printf '%s\n' "${LATEST_VERSIONS[@]}" | jq -R . | jq -s .)" '{"node_version":$versions}')
|
||||||
|
echo "Matrix JSON: $MATRIX_JSON"
|
||||||
|
|
||||||
|
# Setting output with proper delimiter for multiline values
|
||||||
|
echo "versions<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
echo "$MATRIX_JSON" >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
echo "buildnode=$BUILD_NODE" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
build_release:
|
||||||
|
name: Build and Release Node.js
|
||||||
|
needs: get_versions
|
||||||
|
if: needs.get_versions.outputs.buildnode == 1
|
||||||
|
strategy:
|
||||||
|
matrix: ${{ fromJSON(needs.get_versions.outputs.versions) }}
|
||||||
|
uses: ./.github/workflows/build-release-alpine-nodejs.yml
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
with:
|
||||||
|
NodeVersion: ${{ matrix.node_version }}
|
||||||
|
|
||||||
|
|
||||||
4
versions.json
Normal file
4
versions.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[
|
||||||
|
"v20",
|
||||||
|
"v24"
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user