websoft9/.github/workflows/release.yml

176 lines
5.8 KiB
YAML
Raw Normal View History

2023-12-08 03:04:22 +00:00
name: Release to Github and Artifact
2023-07-21 07:19:59 +00:00
on:
workflow_dispatch:
push:
2024-09-04 06:00:12 +00:00
branches:
- main
2023-07-21 07:19:59 +00:00
paths:
2023-09-28 02:27:12 +00:00
- "version.json"
2023-07-21 07:19:59 +00:00
jobs:
upload_artifact:
2023-12-10 02:36:32 +00:00
name: upload_artifact
2023-07-21 07:19:59 +00:00
runs-on: ubuntu-latest
steps:
2023-12-10 03:01:26 +00:00
- uses: actions/checkout@v4
2023-07-21 07:19:59 +00:00
name: Check out code
2023-11-16 00:42:30 +00:00
- name: Version convert
id: convert_version
2023-07-21 07:19:59 +00:00
run: |
2023-09-27 00:40:39 +00:00
version=$(jq -r '.version' version.json)
2023-11-16 00:42:30 +00:00
version_core=${version%%-*}
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION_CORE=$version_core" >> $GITHUB_OUTPUT
if [[ $version == *-* ]]; then
echo "rc release version"
echo "CHANNEL=dev" >> $GITHUB_OUTPUT
else
echo "release version"
echo "CHANNEL=release" >> $GITHUB_OUTPUT
fi
- name: Update CHANGELOG.md
id: update_data
run: |
2023-07-25 05:36:50 +00:00
changelog=$(cat changelog_latest.md)
2023-07-26 02:42:48 +00:00
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$changelog" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
2023-11-16 00:42:30 +00:00
current_date=$(date +%Y-%m-%d)
printf "## ${{ steps.convert_version.outputs.VERSION }} release on $current_date\n$changelog\n$(cat CHANGELOG.md)" > temp.txt
mv temp.txt CHANGELOG.md
- name: Create Zip Archive
run: |
2023-07-21 07:19:59 +00:00
mkdir websoft9 artifacts
cp -r docker websoft9
cp -r cockpit websoft9
cp -r scripts websoft9
cp -r install websoft9
cp -r docs websoft9
2023-09-26 10:21:45 +00:00
cp -r systemd websoft9
cp *.md websoft9
2023-07-21 07:19:59 +00:00
cp version.json websoft9
2023-11-16 00:42:30 +00:00
zip -r websoft9-${{ steps.convert_version.outputs.VERSION_CORE }}.zip websoft9
cp websoft9-${{ steps.convert_version.outputs.VERSION_CORE }}.zip artifacts
2023-08-03 01:19:59 +00:00
cp install/install.sh artifacts
2023-07-24 09:55:37 +00:00
cp version.json artifacts
2023-07-26 08:20:55 +00:00
cp CHANGELOG.md artifacts
2023-11-16 00:42:30 +00:00
cp artifacts/websoft9-${{ steps.convert_version.outputs.VERSION_CORE }}.zip artifacts/websoft9-latest.zip
2023-09-28 02:27:12 +00:00
2024-09-03 07:07:20 +00:00
- name: Upload To cloudflare r2
uses: ryand56/r2-upload-action@latest
2023-07-21 07:19:59 +00:00
with:
2024-09-03 07:07:20 +00:00
r2-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.CLOUDFLARE_SECRET_ID }}
r2-secret-access-key: ${{ secrets.CLOUDFLARE_SECRET_KEY }}
r2-bucket: artifact
source-dir: artifacts
destination-dir: ./${{ steps.convert_version.outputs.CHANNEL }}/websoft9
2023-07-25 05:36:50 +00:00
2023-12-10 02:36:32 +00:00
- name: Create Github Release
2023-07-25 05:36:50 +00:00
uses: softprops/action-gh-release@v1
with:
2023-11-16 00:42:30 +00:00
files: |
version.json
CHANGELOG.md
tag_name: ${{ steps.convert_version.outputs.VERSION }}
2023-12-11 01:27:28 +00:00
name: ${{ steps.convert_version.outputs.VERSION }}
2023-07-26 02:42:48 +00:00
body: ${{ steps.update_data.outputs.CHANGELOG }}
2023-07-25 05:36:50 +00:00
draft: false
2023-12-08 03:04:22 +00:00
prerelease: false
apidocs:
needs: upload_artifact
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Check out code
- name: Get version
run: |
version=$(grep -Po '(?<=LABEL version=").*?(?=")' docker/apphub/Dockerfile)
echo $version
real_version=${version%%-*}
echo "VERSION=$version" >> $GITHUB_ENV
- name: Download redoc.standalone.js
run: wget -O apphub/apidocs/redoc.standalone.js https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js
- name: Run Docker container and get openapi.json
run: |
docker run -d --name apphub -p 8080:8080 websoft9dev/apphub:${{ env.VERSION }}
sleep 5
max_attempts=10
url="http://localhost:8080/openapi.json"
for attempt in $(seq 1 $max_attempts); do
echo "Attempt #$attempt to download $url..."
if wget -O apphub/apidocs/openapi.json "$url"; then
echo "Successfully downloaded $url"
break
else
echo "Failed to download $url. Waiting for 5 seconds before retry..."
sleep 5
fi
done
2024-09-03 02:25:40 +00:00
- name: Prepare apidocs content
run: |
mkdir -p apidocs
cp -r apphub/apidocs/* apidocs/
- name: Compress apidocs content
run: |
zip -r apidocs.zip apidocs
- name: Deploy apidocs content to Cloudflare Pages Dev Environment
run: |
curl -X POST "https://api.cloudflare.com/client/v4/accounts/eb79f13320db531d8cf1f3720966b695/pages/projects/doc-websoft9-com/deployments" \
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}" \
-F "file=@apidocs.zip" \
2024-09-05 01:04:28 +00:00
-F "branch=dev"
2024-09-03 02:25:40 +00:00
# - name: Publish to Cloudflare Pages
# uses: cloudflare/pages-action@v1
# with:
# apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
# accountId: eb79f13320db531d8cf1f3720966b695
# projectName: doc-websoft9-com
# directory: apphub/apidocs
# # Optional: Enable this if you want to have GitHub Deployments triggered
# gitHubToken: ${{ secrets.GITHUB_TOKEN }}
# # Optional: Switch what branch you are publishing to.
# # By default this will be the branch which triggered this workflow
# branch: dev
2023-12-10 02:36:32 +00:00
pages:
name: Build Github Pages
2023-12-10 23:36:08 +00:00
permissions:
contents: read
pages: write
id-token: write
2023-12-10 02:36:32 +00:00
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload entire repository
path: '.'
- name: Deploy to GitHub Pages
id: deployment
2024-08-26 03:58:28 +00:00
uses: actions/deploy-pages@v3