squashed a bunch of workflow build bugs
This commit is contained in:
parent
7655748e8e
commit
468a286fee
3 changed files with 63 additions and 102 deletions
|
|
@ -6,14 +6,14 @@ on:
|
|||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: https://code.forgejo.org/actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
uses: https://code.forgejo.org/actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
|
|
@ -26,32 +26,62 @@ jobs:
|
|||
run: |
|
||||
pyinstaller --onefile --console --name TinyWeb app.py
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: TinyWeb-linux-x64
|
||||
path: dist/TinyWeb
|
||||
if-no-files-found: error
|
||||
- name: Prepare artifact
|
||||
run: |
|
||||
cp dist/TinyWeb TinyWeb-linux-x64
|
||||
chmod +x TinyWeb-linux-x64
|
||||
ls -la TinyWeb-linux-x64
|
||||
|
||||
release:
|
||||
needs: build
|
||||
runs-on: docker
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
- name: Get Release ID
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
id: release
|
||||
run: |
|
||||
TAG="${{ github.ref_name }}"
|
||||
REPO="${{ github.repository }}"
|
||||
TOKEN="${{ secrets.FORGEJO_TOKEN }}"
|
||||
RELEASE_JSON=$(curl -s "https://git.derickphan.com/api/v1/repos/$REPO/releases/tags/$TAG" \
|
||||
-H "Authorization: token $TOKEN")
|
||||
echo "$RELEASE_JSON"
|
||||
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id')
|
||||
echo "release_id=$RELEASE_ID" >> $FORGEJO_OUTPUT
|
||||
|
||||
steps:
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: TinyWeb-linux-x64
|
||||
- name: Upload to Release
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: |
|
||||
FILE=TinyWeb-linux-x64
|
||||
RELEASE_ID="${{ steps.release.outputs.release_id }}"
|
||||
REPO="${{ github.repository }}"
|
||||
TOKEN="${{ secrets.FORGEJO_TOKEN }}"
|
||||
curl -X POST "https://git.derickphan.com/api/v1/repos/$REPO/releases/$RELEASE_ID/assets" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@$FILE"
|
||||
|
||||
- name: Make executable
|
||||
run: chmod +x TinyWeb-linux-x64
|
||||
- name: Login to Registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login registry.derickphan.com -u _ --password-stdin
|
||||
|
||||
- name: Create Release
|
||||
uses: actions/forgejo-release@v2
|
||||
with:
|
||||
direction: upload
|
||||
release-dir: .
|
||||
override: true
|
||||
prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') }}
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
TAG="${{ github.ref_name }}"
|
||||
if [ -z "$TAG" ]; then
|
||||
TAG="latest"
|
||||
fi
|
||||
# Configure Docker daemon with DNS
|
||||
mkdir -p ~/.docker
|
||||
cat > ~/.docker/daemon.json << 'EOF'
|
||||
{
|
||||
"dns": ["8.8.8.8", "1.1.1.1"],
|
||||
"builder": {
|
||||
"features": {
|
||||
"buildkit": true
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
# Restart docker to pick up new config
|
||||
pkill dockerd || true
|
||||
sleep 2
|
||||
# Build with buildkit
|
||||
DOCKER_BUILDKIT=1 docker build --network=host -t registry.derickphan.com/tinyweb:$TAG .
|
||||
docker push registry.derickphan.com/tinyweb:$TAG
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue