Update .github/workflows/create-release.yaml
Some checks failed
Build and push image to DockerHub / build (push) Has been cancelled
Some checks failed
Build and push image to DockerHub / build (push) Has been cancelled
This commit is contained in:
93
.github/workflows/create-release.yaml
vendored
93
.github/workflows/create-release.yaml
vendored
@@ -1,60 +1,77 @@
|
|||||||
name: "Create Release"
|
name: "Create Gitea Release"
|
||||||
|
|
||||||
on: # yamllint disable-line rule:truthy
|
# This workflow is triggered manually from the Gitea Actions UI
|
||||||
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
RELEASE_TAG:
|
RELEASE_TAG:
|
||||||
description: 'v{Major}.{Minor}.{Patch}'
|
description: 'The release tag to create, formatted as v{Major}.{Minor}.{Patch}'
|
||||||
|
required: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
name: "Release"
|
name: "Release"
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
runs-on: "ubuntu-latest"
|
runs-on: "ubuntu-latest"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
# Step 1: Check out the repository source code and its submodules.
|
||||||
|
# The TOKEN_GITEA is used here to grant permission for the later 'git push'.
|
||||||
- name: Checkout source
|
- name: Checkout source
|
||||||
uses: actions/checkout@v3
|
uses: "actions/checkout@v4"
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.ACTIONS_ACCESS_TOKEN }}
|
token: ${{ secrets.TOKEN_GITEA }}
|
||||||
submodules: true
|
submodules: true
|
||||||
|
|
||||||
- name: Create branch and tag submodule
|
# Step 2: Create a new release branch, update the submodule to the specified tag,
|
||||||
|
# and push the new branch to the Gitea repository.
|
||||||
|
- name: Create Branch and Update Submodule
|
||||||
run: |
|
run: |
|
||||||
git config user.email "actions@github.com"
|
# Configure git user for the commit
|
||||||
git config user.name "actions-user"
|
git config user.email "actions@gitea.local"
|
||||||
git submodule update --init --remote
|
git config user.name "Gitea Actions"
|
||||||
|
|
||||||
|
# Create the new release branch
|
||||||
git checkout -b 'release-${{ inputs.RELEASE_TAG }}'
|
git checkout -b 'release-${{ inputs.RELEASE_TAG }}'
|
||||||
|
|
||||||
|
# Enter the submodule directory, fetch the latest tags, and check out the correct one.
|
||||||
|
# This points the submodule to the specific commit associated with the release tag.
|
||||||
(cd calcom && git fetch --tags origin && git checkout 'refs/tags/${{ inputs.RELEASE_TAG }}')
|
(cd calcom && git fetch --tags origin && git checkout 'refs/tags/${{ inputs.RELEASE_TAG }}')
|
||||||
|
|
||||||
|
# Stage and commit the change to the submodule pointer
|
||||||
git add calcom
|
git add calcom
|
||||||
git commit -m "tag version Cal.com version ${{ inputs.RELEASE_TAG }}"
|
git commit -m "Update submodule to Cal.com version ${{ inputs.RELEASE_TAG }}"
|
||||||
|
|
||||||
|
# Push the newly created release branch to the remote Gitea repository
|
||||||
git push origin 'release-${{ inputs.RELEASE_TAG }}'
|
git push origin 'release-${{ inputs.RELEASE_TAG }}'
|
||||||
|
|
||||||
# note: instead of secrets.GITHUB_TOKEN here, we need to use a PAT
|
# Step 3: Call the Gitea API to create the official release object.
|
||||||
# so that the release creation triggers the image build workflow
|
# This uses the same API token to authorize the action.
|
||||||
- name: "Create release"
|
- name: "Create Gitea Release"
|
||||||
uses: "actions/github-script@v6"
|
env:
|
||||||
with:
|
GITEA_TOKEN: ${{ secrets.TOKEN_GITEA }}
|
||||||
github-token: "${{ secrets.ACTIONS_ACCESS_TOKEN }}"
|
GITEA_API_URL: ${{ gitea.instance }}/api/v1
|
||||||
script: |
|
OWNER: ${{ gitea.repository_owner }}
|
||||||
const isPreRelease = '${{ inputs.RELEASE_TAG }}'.includes('-rc');
|
REPO: ${{ gitea.repository_name }}
|
||||||
try {
|
run: |
|
||||||
const response = await github.rest.repos.createRelease({
|
# Determine if the tag indicates a pre-release
|
||||||
draft: false,
|
is_prerelease=false
|
||||||
generate_release_notes: true,
|
if [[ "${{ inputs.RELEASE_TAG }}" == *"-rc"* || "${{ inputs.RELEASE_TAG }}" == *"-beta"* ]]; then
|
||||||
body: 'For Cal.com release details, see: https://github.com/calcom/cal.com/releases/tag/${{ inputs.RELEASE_TAG }}',
|
is_prerelease=true
|
||||||
name: '${{ inputs.RELEASE_TAG }}',
|
fi
|
||||||
target_commitish: 'release-${{ inputs.RELEASE_TAG }}',
|
|
||||||
owner: context.repo.owner,
|
|
||||||
prerelease: isPreRelease,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
tag_name: '${{ inputs.RELEASE_TAG }}',
|
|
||||||
});
|
|
||||||
|
|
||||||
core.exportVariable('RELEASE_ID', response.data.id);
|
echo "Creating release ${{ inputs.RELEASE_TAG }}..."
|
||||||
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
|
echo "Is prerelease: $is_prerelease"
|
||||||
} catch (error) {
|
|
||||||
core.setFailed(error.message);
|
# Use curl to send a POST request to the Gitea API's 'create release' endpoint
|
||||||
}
|
curl --fail --silent --show-error -L -X POST \
|
||||||
|
-H "accept: application/json" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
"${GITEA_API_URL}/repos/${OWNER}/${REPO}/releases" \
|
||||||
|
-d '{
|
||||||
|
"tag_name": "${{ inputs.RELEASE_TAG }}",
|
||||||
|
"target_commitish": "release-${{ inputs.RELEASE_TAG }}",
|
||||||
|
"name": "${{ inputs.RELEASE_TAG }}",
|
||||||
|
"body": "For Cal.com release details, see: https://github.com/calcom/cal.com/releases/tag/${{ inputs.RELEASE_TAG }}",
|
||||||
|
"prerelease": '${is_prerelease}'
|
||||||
|
}'
|
||||||
Reference in New Issue
Block a user