79 lines
2.2 KiB
YAML
79 lines
2.2 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- master
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
# Replace this runtime setup block with the stack this project uses.
|
|
# Examples:
|
|
# - Node: actions/setup-node@v4
|
|
# - Python: actions/setup-python@v5
|
|
# - Go: actions/setup-go@v5
|
|
# - Rust: dtolnay/rust-toolchain@stable
|
|
- name: Setup runtime
|
|
run: echo "Configure PROJECT_STACK runtime here"
|
|
|
|
- name: Install dependencies
|
|
run: INSTALL_COMMAND
|
|
|
|
- name: Audit dependencies
|
|
run: AUDIT_COMMAND
|
|
|
|
- name: Lint
|
|
run: LINT_COMMAND
|
|
|
|
- name: Test
|
|
run: TEST_COMMAND
|
|
|
|
- name: Build
|
|
run: BUILD_COMMAND
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: PROJECT_NAME-artifacts
|
|
path: |
|
|
ARTIFACT_OUTPUT_DIRECTORY/**
|
|
|
|
- name: Publish latest package
|
|
if: ${{ env.REGISTRY_TOKEN != '' }}
|
|
shell: bash
|
|
run: |
|
|
app_version="PROJECT_VERSION"
|
|
package_version="${app_version}-${GITHUB_SHA::7}"
|
|
latest_url="https://git.wilkensxl.de/api/packages/REPOSITORY_OWNER/generic/PACKAGE_NAME/latest"
|
|
|
|
for artifact in ARTIFACT_OUTPUT_DIRECTORY/*; do
|
|
[ -f "$artifact" ] || continue
|
|
file_name="$(basename "$artifact")"
|
|
|
|
curl --fail-with-body \
|
|
--user "REPOSITORY_OWNER:${REGISTRY_TOKEN}" \
|
|
--upload-file "$artifact" \
|
|
"https://git.wilkensxl.de/api/packages/REPOSITORY_OWNER/generic/PACKAGE_NAME/${package_version}/${file_name}"
|
|
done
|
|
|
|
curl --silent --show-error --user "REPOSITORY_OWNER:${REGISTRY_TOKEN}" --request DELETE "${latest_url}" || true
|
|
|
|
for artifact in ARTIFACT_OUTPUT_DIRECTORY/*; do
|
|
[ -f "$artifact" ] || continue
|
|
file_name="$(basename "$artifact")"
|
|
|
|
curl --fail-with-body \
|
|
--user "REPOSITORY_OWNER:${REGISTRY_TOKEN}" \
|
|
--upload-file "$artifact" \
|
|
"${latest_url}/${file_name}"
|
|
done
|