Merge pull request 'Add Forgejo Actions' (#23) from forgejo-actions into main
All checks were successful
Run Tests on Code / run-tests (push) Successful in 0s
All checks were successful
Run Tests on Code / run-tests (push) Successful in 0s
Reviewed-on: #23
This commit is contained in:
commit
f0c96012ce
3 changed files with 88 additions and 71 deletions
72
.forgejo/workflows/build+release.yml
Normal file
72
.forgejo/workflows/build+release.yml
Normal file
|
@ -0,0 +1,72 @@
|
|||
name: 'Build and Release Binary File'
|
||||
author: 'Neshura'
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+'
|
||||
- '[0-9]+.[0-9]+.[0-9]+rc[0-9]+'
|
||||
jobs:
|
||||
run-tests:
|
||||
runs-on: docker
|
||||
steps:
|
||||
-
|
||||
name: Placeholder
|
||||
run: echo Placeholder Job
|
||||
|
||||
build:
|
||||
needs: test
|
||||
if: success()
|
||||
runs-on: docker
|
||||
container: rust:latest
|
||||
steps:
|
||||
-
|
||||
name: Installing Node
|
||||
run: apt update && apt install -y nodejs
|
||||
-
|
||||
name: Checking Out Repository Code
|
||||
uses: https://code.forgejo.org/actions/checkout@v3
|
||||
-
|
||||
name: Compiling To Linux Target
|
||||
run: |
|
||||
cargo build -r
|
||||
mv target/release/cloudflare-dns-updater cloudflare-dns-updater-linux-amd64
|
||||
-
|
||||
name: Uploading Build Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: cloudflare-dns-updater-linux-amd64
|
||||
path: cloudflare-dns-updater-linux-amd64
|
||||
if-no-files-found: error
|
||||
|
||||
upload-release:
|
||||
needs: build
|
||||
if: success()
|
||||
runs-on: docker
|
||||
steps:
|
||||
-
|
||||
name: Downloading All Build Artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
-
|
||||
name: Rearrange Artifact Paths
|
||||
run: |
|
||||
mkdir release
|
||||
mv cloudflare-dns-updater-linux-amd64/cloudflare-dns-updater-linux-amd64 release/cloudflare-dns-updater-linux-amd64
|
||||
-
|
||||
name: Upload Artifacts As Generic Packages
|
||||
run: |
|
||||
echo 'curl -v --user ${{ secrets.FORGEJO_USERNAME }}:${{ secrets.FORGEJO_TOKEN }} \
|
||||
--upload-file release/cloudflare-dns-updater-linux-amd64 \
|
||||
https://forgejo.neshweb.net/api/packages/${{ secrets.FORGEJO_USERNAME }}/generic/${{ github.event.repository.name }}/${{ github.ref_name }}/chellaris-rust-api-linux-amd64'
|
||||
curl -v --user ${{ secrets.FORGEJO_USERNAME }}:${{ secrets.FORGEJO_TOKEN }} \
|
||||
--upload-file release/cloudflare-dns-updater-linux-amd64 \
|
||||
https://forgejo.neshweb.net/api/packages/${{ secrets.FORGEJO_USERNAME }}/generic/${{ github.event.repository.name }}/${{ github.ref_name }}/chellaris-rust-api-linux-amd64
|
||||
-
|
||||
name: Release New Version
|
||||
uses: actions/forgejo-release@v1
|
||||
with:
|
||||
direction: upload
|
||||
url: https://forgejo.neshweb.net
|
||||
release-dir: release
|
||||
token: ${{ secrets.FORGEJO_TOKEN }}
|
||||
tag: ${{ github.ref_name }}
|
16
.forgejo/workflows/test.yml
Normal file
16
.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
name: 'Run Tests on Code'
|
||||
author: 'Neshura'
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
branches:
|
||||
- '**'
|
||||
jobs:
|
||||
run-tests:
|
||||
runs-on: docker
|
||||
steps:
|
||||
-
|
||||
name: Placeholder
|
||||
run: echo Placeholder Job
|
|
@ -1,71 +0,0 @@
|
|||
image: 3.10.8-slim-buster
|
||||
|
||||
variables:
|
||||
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/linux/$CI_COMMIT_TAG/"
|
||||
|
||||
.deploy:
|
||||
rules:
|
||||
# Regex magic copied from Neshura/page-test, only deploys on x.y.z or higher (x.y) Tags
|
||||
- if: $CI_COMMIT_TAG =~ /^((([\d])+\.){1,2}[\d]+)\s*$/ && $CI_COMMIT_TAG
|
||||
|
||||
stages:
|
||||
- build
|
||||
- upload
|
||||
- release
|
||||
|
||||
## Docker steps
|
||||
|
||||
build:
|
||||
image: rust:bullseye
|
||||
stage: build
|
||||
|
||||
variables:
|
||||
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH
|
||||
CACHING:
|
||||
|
||||
script:
|
||||
- echo "Compiling the code..."
|
||||
- cargo build -r
|
||||
- echo "Compile complete."
|
||||
|
||||
after_script:
|
||||
- echo JOB_ID=$CI_JOB_ID >> job.env
|
||||
- mkdir ./artifacts
|
||||
- cp /builds/Neshura/cloudflare-dns-updater/target/release/cloudflare-dns-updater ./artifacts/
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- ./artifacts/
|
||||
reports:
|
||||
dotenv: job.env
|
||||
|
||||
rules:
|
||||
- !reference [.deploy, rules]
|
||||
|
||||
upload:
|
||||
needs:
|
||||
- job: build
|
||||
artifacts: true
|
||||
image: curlimages/curl:latest
|
||||
stage: upload
|
||||
script:
|
||||
- |
|
||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file artifacts/cloudflare-dns-updater "${PACKAGE_REGISTRY_URL}/cloudflare-dns-updater"
|
||||
rules:
|
||||
- !reference [.deploy, rules]
|
||||
|
||||
Tag Release:
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
rules:
|
||||
- !reference [.deploy, rules]
|
||||
script:
|
||||
- echo "running Release Job, attaching Artifact from Job $JOB_ID"
|
||||
release:
|
||||
tag_name: '$CI_COMMIT_TAG'
|
||||
description: '$CI_COMMIT_TAG'
|
||||
assets:
|
||||
links:
|
||||
- name: "cloudflare-dns-updater"
|
||||
url: "${PACKAGE_REGISTRY_URL}/cloudflare-dns-updater"
|
||||
|
Loading…
Reference in a new issue