name: Release on: push: branches: [master] paths-ignore: - '**.md' - '.forgejo/**' jobs: release: runs-on: docker defaults: run: shell: bash 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: | LATEST=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-version:refname | head -1) if [ -z "$LATEST" ]; then # First release — use version from package.json NEW=$(node -p "require('./package.json').version") else IFS='.' read -r maj min pat <<< "${LATEST#v}" NEW="${maj}.${min}.$((pat + 1))" fi echo "version=$NEW" >> $GITHUB_OUTPUT echo "tag=v$NEW" >> $GITHUB_OUTPUT - name: Install dependencies run: npm ci - name: Set version in package.json run: npm version ${{ steps.version.outputs.version }} --no-git-tag-version --allow-same-version - name: Build Linux AppImage run: npm run build:linux env: # Подавляем попытку electron-builder публиковать на GitHub GH_TOKEN: "" - name: Find built AppImage id: artifact run: | APPIMAGE=$(ls dist/*.AppImage | head -1) echo "path=$APPIMAGE" >> $GITHUB_OUTPUT echo "name=$(basename $APPIMAGE)" >> $GITHUB_OUTPUT - name: Create and push tag env: 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" git tag "$TAG" git push origin "$TAG" - name: Create Forgejo release id: release env: TAG: ${{ steps.version.outputs.tag }} TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | BODY=$(cat <<'NOTES' Автоматический релиз. NOTES ) RELEASE=$(curl -sf -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/json" \ -d "{\"tag_name\":\"${TAG}\",\"name\":\"Aero Mail ${TAG}\",\"body\":\"${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}"