name: Release on: push: branches: [master] workflow_dispatch: jobs: release: # Пропускаем коммиты от CI (bump версии) if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: docker container: image: node:20-bookworm steps: - name: Checkout (full history for tags) uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Determine next version id: version run: node .forgejo/version.js - name: Install dependencies run: npm ci - name: Bump version in package.json and commit back env: VERSION: ${{ steps.version.outputs.version }} TAG: ${{ steps.version.outputs.tag }} GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git config user.email "ci@vodyanoysh.ru" git config user.name "Forgejo CI" git remote set-url origin "https://x-token:${GIT_TOKEN}@git.vodyanoysh.ru/vodyanoy/aero-mail.git" npm version "${VERSION}" --no-git-tag-version --allow-same-version git add package.json package-lock.json git diff --cached --quiet || git commit -m "chore: bump version to ${VERSION} [skip ci]" git push origin master git tag "${TAG}" git push origin "${TAG}" - name: Build Linux AppImage run: npm run build && npx electron-builder --linux --publish=never - name: Find built AppImage id: artifact run: | APPIMAGE=$(ls dist/aero-mail-*.AppImage | head -1) echo "path=$APPIMAGE" >> "$GITHUB_OUTPUT" echo "name=$(basename $APPIMAGE)" >> "$GITHUB_OUTPUT" - name: Create Forgejo release id: release env: TAG: ${{ steps.version.outputs.tag }} TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | RELEASE=$(curl -sf -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/json" \ -d "{\"tag_name\":\"${TAG}\",\"name\":\"Aero Mail ${TAG}\",\"body\":\"Автоматический релиз.\",\"draft\":false,\"prerelease\":false}" \ "https://git.vodyanoysh.ru/api/v1/repos/vodyanoy/aero-mail/releases") echo "id=$(echo "$RELEASE" | python3 -c 'import sys,json; print(json.load(sys.stdin)["id"])')" >> "$GITHUB_OUTPUT" - name: Upload AppImage to release env: TOKEN: ${{ secrets.GITHUB_TOKEN }} RELEASE_ID: ${{ steps.release.outputs.id }} ASSET_PATH: ${{ steps.artifact.outputs.path }} ASSET_NAME: ${{ steps.artifact.outputs.name }} run: | curl -sf -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/octet-stream" \ --data-binary @"${ASSET_PATH}" \ "https://git.vodyanoysh.ru/api/v1/repos/vodyanoy/aero-mail/releases/${RELEASE_ID}/assets?name=${ASSET_NAME}"