name: Automated Builds on: workflow_dispatch: pull_request: branches: - main paths-ignore: - '**.md' - '.github/ISSUE_TEMPLATE/*' - '.docs/changelog' push: branches: - main paths-ignore: - '**.md' - '.github/ISSUE_TEMPLATE/*' - '.docs/changelog' jobs: prepare-source: name: ⚙️ Prepare Source runs-on: ubuntu-22.04 outputs: release_version: ${{ steps.get_version.outputs.RELEASE_VERSION }} release_tag: ${{ steps.get_version.outputs.RELEASE_TAG }} steps: - name: Checkout code uses: actions/checkout@v4 - name: Extract Version and Update version.h id: get_version run: | CHANGELOG_FILE="./docs/changelog" VERSION_FILE="src/lindbergh/version.h" if [[ ! -f "$CHANGELOG_FILE" ]]; then echo "Error: Changelog file '$CHANGELOG_FILE' not found." exit 1 fi VERSION=$(awk '/^## \[/ { match($0, /\[([^]]+)\]/, arr); print arr[1]; exit }' "$CHANGELOG_FILE") # Check if a version was actually extracted if [[ -z "$VERSION" ]]; then echo "Error: Could not find version in '$CHANGELOG_FILE'. Expected format like '## [X.Y.Z]' near the top." exit 1 fi echo "Found version: $VERSION" MAJOR=$(echo $VERSION | cut -d. -f1) MINOR=$(echo $VERSION | cut -d. -f2) UPDATE=$(echo $VERSION | cut -d. -f3) if [ -z "$UPDATE" ]; then UPDATE=0 fi if [[ ! -f "$VERSION_FILE" ]]; then echo "Error: Version file '$VERSION_FILE' not found." exit 1 fi sed -i "s/\(#define MAJOR_VERSION \).*/\1$MAJOR/" "$VERSION_FILE" sed -i "s/\(#define MINOR_VERSION \).*/\1$MINOR/" "$VERSION_FILE" sed -i "s/\(#define UPDATE_VERSION \).*/\1$UPDATE/" "$VERSION_FILE" echo "Updated $VERSION_FILE with version $MAJOR.$MINOR.$UPDATE" echo "RELEASE_VERSION=$VERSION" >> $GITHUB_OUTPUT echo "RELEASE_TAG=v$VERSION" >> $GITHUB_OUTPUT - name: Upload version.h artifact uses: actions/upload-artifact@v4 with: name: version-file path: src/lindbergh/version.h linux-appimage: name: 📦 Linux AppImage needs: prepare-source uses: "./.github/workflows/appimage-build.yml" linux-build: name: 💻 Linux needs: [prepare-source, linux-appimage] uses: "./.github/workflows/linux-build.yml" linux-flatpak: name: 📦 Linux Flatpak needs: [prepare-source, linux-appimage] uses: "./.github/workflows/flatpak-build.yml" create-release: name: 📤 Create Release needs: [linux-build, linux-flatpak, linux-appimage, prepare-source] runs-on: ubuntu-22.04 if: github.event_name == 'push' && github.ref == 'refs/heads/main' steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Download Artifacts uses: actions/download-artifact@v4 with: path: ./artifacts/ - name: Display Downloaded Artifacts run: find ./artifacts/ - name: Create Release uses: "marvinpinto/action-automatic-releases@latest" with: repo_token: "${{ secrets.GITHUB_TOKEN }}" automatic_release_tag: ${{ needs.prepare-source.outputs.release_tag }} prerelease: false title: "Build ${{ needs.prepare-source.outputs.release_tag }}" files: | ./artifacts/linux-flatpak/lindbergh-loader.flatpak ./artifacts/linux-build/build.tar.gz ./artifacts/linux-appimage/lindbergh-loader.AppImage