ci: migrate from GitHub Actions to Gitea Actions
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
name: Create pre-release
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-if-release-needed:
|
||||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
latest-commit-sha: ${{ steps.get-latest-commit.outputs.result }}
|
||||
has-new-commits: ${{ steps.check-for-new-commits.outputs.has-new-commits }}
|
||||
steps:
|
||||
- name: Extract branch name
|
||||
id: extract-branch-name
|
||||
run: |
|
||||
echo "result=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_OUTPUT"
|
||||
- name: Sanity checks
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && steps.extract-branch-name.outputs.result != 'develop' }}
|
||||
run: |
|
||||
echo "::error::this workflow can only be run on the \"develop\" branch"
|
||||
exit 1
|
||||
|
||||
- name: Get latest nightly-tagged commit
|
||||
id: get-latest-tag
|
||||
env:
|
||||
CI_RELEASE_TOKEN: ${{ secrets.CI_RELEASE_TOKEN }}
|
||||
run: |
|
||||
api_url="${GITEA_API_URL:-https://git.illegalfiles.icu/api/v1}"
|
||||
repo="${GITEA_REPOSITORY:-vlad.os/LuaCsForBarotraumaEP}"
|
||||
|
||||
ref=$(curl -s -H "Authorization: token $CI_RELEASE_TOKEN" \
|
||||
"$api_url/repos/$repo/tags" | \
|
||||
jq -r '.[] | select(.name == "nightly") | .commit.sha // empty')
|
||||
|
||||
if [[ -z "$ref" ]]; then
|
||||
echo "result=tag-doesnt-exist" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "result=$ref" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Get latest commit on dev branch
|
||||
id: get-latest-commit
|
||||
env:
|
||||
CI_RELEASE_TOKEN: ${{ secrets.CI_RELEASE_TOKEN }}
|
||||
run: |
|
||||
api_url="${GITEA_API_URL:-https://git.illegalfiles.icu/api/v1}"
|
||||
repo="${GITEA_REPOSITORY:-vlad.os/LuaCsForBarotraumaEP}"
|
||||
|
||||
sha=$(curl -s -H "Authorization: token $CI_RELEASE_TOKEN" \
|
||||
"$api_url/repos/$repo/branches/develop" | \
|
||||
jq -r '.commit.id // empty')
|
||||
|
||||
echo "result=$sha" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Check for new commits
|
||||
id: check-for-new-commits
|
||||
if: ${{ steps.get-latest-tag.outputs.result != 'tag-doesnt-exist' }}
|
||||
env:
|
||||
LATEST_TAGGED_SHA: "${{ steps.get-latest-tag.outputs.result }}"
|
||||
LATEST_SHA: "${{ steps.get-latest-commit.outputs.result }}"
|
||||
run: |
|
||||
if [[ -z "$LATEST_TAGGED_SHA" ]]; then
|
||||
echo "::error::LATEST_TAGGED_SHA env var is invalid"
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "$LATEST_SHA" ]]; then
|
||||
echo "::error::LATEST_TAGGED_SHA env var is invalid"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$LATEST_TAGGED_SHA" == "$LATEST_SHA" ]]; then
|
||||
echo "has-new-commits=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "has-new-commits=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
publish-release:
|
||||
needs: [check-if-release-needed]
|
||||
if: ${{ needs.check-if-release-needed.outputs.has-new-commits == 'true' }}
|
||||
uses: ./.gitea/workflows/publish-release.yml
|
||||
with:
|
||||
target: ${{ needs.check-if-release-needed.outputs.latest-commit-sha }}
|
||||
tag: nightly
|
||||
prerelease: true
|
||||
Reference in New Issue
Block a user